1 2 3 6 9 18 27 54...
Related Links:
- More Series Programs
- Number Pattern Programs
- Star Pattern Programs in C
- Alphabet Pattern Programs in C
int main()
{
int a=1,b=2,i,n=10;
printf("%d %d ",a, b);
for(i=3;i<=n;i++)
{
if(i%2==1)
{
a=a*3;
printf("%d ",a);
}
else
{
b=b*3;
printf("%d ",b);
}
}
return 0;
}
Related Links:
- More Series Programs
- Number Pattern Programs
- Star Pattern Programs in C
- Alphabet Pattern Programs in C
1+2=3 ok
ReplyDeletebut how come 2+3=6, is should be 5 there.
it is multiplication
DeleteThis sequence is computed by adding the value to itself if it is odd, and by adding the previous value to it if it is even.
Deletefor(i=0;i<=20;i++)
ReplyDelete{
if(a%2!=0) //all the odd positions like 1,3,5 have 0,2,4 so i-1
{
a=i-1;
printf("%d",a);
}
else
{
a=(i/2-1)*3; // nos in even positions have common difference 3 so (*3)
printf("%d",a);
}
}
This comment has been removed by the author.
ReplyDeleteADD EVEN DIGIT NUMBERS WITH +3 AND FOR ODD ONES ITS +2
ReplyDelete