Can someone tell me how the series is to be implemented in c
1,1,1 2,1 2 3,1 2 3 4 5, 1 2 3 4 5 6 7 8
here is my code
but i am not able to get the answer

#include<stdio.h>
int i,n1=0,n2=1,n3,n;
void main()
{
printf("\n Enter Value Of N  \n");
scanf("%d",&n);
printf("%-2d",n1);
for(i=0;i<=n;i++)
fib(n);
}

int fib(int n)
{
n1=0,n2=1;
printf("%-2d",n1);
for(i=0;i<n;i++)
{
n3=n1+n2;
n1=n2;
n2=n3;
printf("%-2d",n3);
}
}

what is the series all about... is there any general formula for this?... give an example... like if n =3, output should be?...

my problem is to generate the following series
1,1,1 2,1 2 3,1 2 3 4 5, 1 2 3 4 5 6 7 8

i dont have any formula for this
series means the sequence in which the numbers must be generated
for example you can take the fibonacci series

mine is just a series and must follow the following sequence

1,1,1 2,1 2 3,1 2 3 4 5, 1 2 3 4 5 6 7 8

some one plz help me!!!

It goes like this:
n(0) = 1;
n(1) = 1;
n(2) = n(1), n(2) //so it's actually two numbers
n(3) = n(1), n(2), n(3)...

Bottom line is: First two numbers just copy.
The print others in a for loop

cant get you !!
can you just tell me in elaborated format

on how to generate this series
1,1,1 2,1 2 3,1 2 3 4 5,1 2 3 4 5 6 7 8

const int N = 6;

int n1 = 1, n2 = 0;
int i, k, n;

for (k = 0; k < N; ++k) {
n = n1 + n2;
for (i = 1; i <= n; ++i)
printf(" %d",i);
putchar(',');
n1 = n2;
n2 = n;
}
putchar('\n');

But I don't want the last set to end with a (,). Could you give me code without the last printed (,)? Pleazzzzzzzzzzz!

Well, srivtsan, finally your hard work of asking here, here, here and over here has payed off. ;)

tanq Arkm
i was not able to get the idea
how did you get the idea Arkm ?
n1 = n2;
n2 = n;
i guess i missed out the logic only in the above two steps in my code
i was breaking my head for the past 48 hrs for getting this series

tanq Aia for spending your valuable time in my problem
i never new that even you are looking for the same series generation!!
i dont know why u want the series to end without a ,
there is nothing wrong if you get a , after the series is genetrated
if you want i will modify it and give you!

>i was not able to get the idea
>how did you get the idea Arkm ?
Do you know what a Fibonacci number is?
If you haven't grasp that the exercise loses its value.

>i dont know why u want the series to end without a ,
>there is nothing wrong if you get a , after the series is genetrated
>if you want i will modify it and give you!

No, thank you, I was playing. I happened to find your posts in three places I frequent. So I made a search with the series to see if you posted somewhere else, and certainly you did.
I thought you had it for sure after the answer in Yahoo, and the clear clue that Salem gave you at Cboard. ;)

#include <stdio.h>

const size_t fibonacci(const size_t n);
void display(const size_t m);

int main(void)
{
display(6);
return 0;
}

const size_t fibonacci(const size_t n)
{
return (n < 2 ? n : fibonacci(n-1) + fibonacci(n-2));
}

void display(const size_t m)
{
size_t n;
for (n = 1; n <= m; n++) {
size_t j, f;

f = fibonacci(n);
for (j = 1; j <= f; ++j)
printf("%d", j);
if (n != m)
putchar(',');
}
}