Created
July 26, 2015 17:40
-
-
Save SohanChy/933b319c6a7962f20552 to your computer and use it in GitHub Desktop.
Printf n number of Fibonacci numbers using recursion in C
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 fibo(int n, int first, int second); | |
int main() | |
{ | |
int first = 0, second = 1; | |
fibo(10, first, second); | |
return 0; | |
} | |
void fibo(int n, int first, int second) | |
{ | |
if(n != 0) | |
{ | |
printf(" %d",first); | |
int temp = first; | |
first = second; | |
second = temp + second; | |
fibo(n-1, first, second); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment