fork download
  1. #include <stdio.h>
  2.  
  3. int F(int n){ return (n<=1)?n:F(n-1)+F(n-2); }
  4.  
  5. int main(){
  6. int n;
  7. printf("Enter number of terms: ");
  8. scanf("%d",&n);
  9. for(int i=0;i<n;i++) printf("%d ",F(i));
  10. }
  11.  
Success #stdin #stdout 0s 5308KB
stdin
7
stdout
Enter number of terms: 0 1 1 2 3 5 8