Skip to content

Instantly share code, notes, and snippets.

@SohanChy
Created July 26, 2015 17:40
Show Gist options
  • Save SohanChy/933b319c6a7962f20552 to your computer and use it in GitHub Desktop.
Save SohanChy/933b319c6a7962f20552 to your computer and use it in GitHub Desktop.
Printf n number of Fibonacci numbers using recursion in C
#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