#include<stdio.h>
#include<conio.h>
int fib(int n)
{
int f;
if (n==0)f=0;
else if(n==1)f=1;
else f=fib(n-2)+fib(n-1);
return f;
}
void main()
{
int n;
printf("masukkan n: ");
scanf("%d",&n);
printf("bilangan fibonacci dari %d = %d",n,fib(n));
getch();
}
Langganan:
Posting Komentar (Atom)
0 Response to "program fibonaci bahasa c"
Posting Komentar