Problem with recursive function for an expression
Hey everyone i need help with this function that displays the result of the following expression : expr=1/1+2/2+3/3+5/4+8/5+...
where the numerator represents a fibonaci number.
Code:
#include<stdio.h>
int fibo(int n)
{
if(n==0 || n==1)
return 1;
return fibo(n-1)+fibo(n-2);
}
float expr(int n)
{
if(n==1)
return 1;
return (fibo(n)/(n))+expr(n-1);
}
int main()
{
int n,m=1;
printf("dami n");
scanf("%d",&n);
printf("fibonaci de %d=%d\n",n,fibo(n));
printf("expresie de %d=%f",n,expr(n));
}