/* * compute elements of the Fibonacci sequence using recursion * (not efficient, but simple!) */ #include /* compute n-th element of sequence */ long fib(long n) { if (n <= 1) { return 1; } else { return fib(n-1) + fib(n-2); } } /* main program */ int main(void) { long n; printf("enter index of the element you want\n"); if (scanf("%ld", &n) == 1) { printf("element %ld is %ld\n", n, fib(n)); } else { printf("not number\n"); return 1; } return 0; }