/* Recursive program to print Fibonacci sequence. */ #include double fib(int n) { if (n == 0 || n == 1) { /* First two terms */ return 1.0; /* fib is 1 */ } else { /* Otherwise sum the 2 previous terms */ return fib(n-1) + fib(n-2); } } main() { double value; int n=0; do { value = fib(n); printf("%2.0f\n", value); /* display */ n++; /* move on */ } while (value < 1000.0); return 0; }