#include<stdio.h>
#include<math.h>
main( )
{
int a, b;
printf("Enter a value:");
scanf("%d", &a);
b = solve(a);
getch( );
}
solve(int a)
{
int b;
if (a == 1)
{
b = 2;
printf("%d", b);
return b;
}
else
{
b = solve2 (a - pow(-1,a));
printf("%d",b);
return b;
}
}
solve2(int a)
{
int b;
if (a == 1)
{
b = 2;
printf("%d", b);
return b;
}
else
{
b = solve (a - pow(-1,a));
printf("%d",b);
return b;
}
}
the program doesn't exit now but instead of having the output 2,1,4,3,6,5,8,7...
it shows 2 if i input a=1
1 if i input a=2
4 if i input a=3
and so on
but i need the whole series in the output.. >.< how do i do it?