Include
Include
h>
int main() {
int i, n;
int t1 = 0, t2 = 1;
scanf("%d", &n);
t1 = t2;
t2 = nextTerm;
nextTerm = t1 + t2;
return 0;
Run Code
Output
Let us suppose n = 10. First, we have printed the first two terms of the Fibonacci sequence before
using a for loop to print the next n terms.
i t1 t2 nextTerm
3 0 1 1
4 1 1 2
5 1 2 3
6 2 3 5
7 3 5 8
8 5 8 13
9 8 13 21
10 13 21 34