Before we start coding lets know what exactly Fibonacci Sequence is?
A series of a number in which each number is sum of the two preceding numbers.
For example, 1,1,2,3,5,8,13,21,34,55,89.. is the simplest fibonacci series.
A series of a number in which each number is sum of the two preceding numbers.
For example, 1,1,2,3,5,8,13,21,34,55,89.. is the simplest fibonacci series.
Most related
SOURCE CODE
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #include< stdio.h> void main() { int i, n, a = 0, b = 1, nxt; printf("Enter the number of terms: \n"); scanf("%d",&n); printf("The Fibonacci series upto %d term is:\n",n); for(i = 1; i <= n; i++) { printf("%d \t",a); nxt = a + b; a = b; b = nxt; } } |
No comments:
Post a Comment