Created
May 4, 2020 12:32
-
-
Save snghnishant/fd72b865e6d888c987f353647482398f to your computer and use it in GitHub Desktop.
Fibonacci series up to n digits using recursion with linear runtime.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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