Skip to content

Instantly share code, notes, and snippets.

@snghnishant
Created May 4, 2020 12:32
Show Gist options
  • Save snghnishant/fd72b865e6d888c987f353647482398f to your computer and use it in GitHub Desktop.
Save snghnishant/fd72b865e6d888c987f353647482398f to your computer and use it in GitHub Desktop.
Fibonacci series up to n digits using recursion with linear runtime.
#include<stdio.h>
void fb(int n, int a, int b){
if(n<=0){
return ;
}
else if(n==1){
printf("%d\t", a);
return ;
}else{
printf("%d\t", a);
}
return fb(n-1, b, a+b);
}
int main(){
int x;
scanf("%d", &x);
fb(x,0,1);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment