如题所述
代码文本:
#include "stdio.h"
int Sum_Fib(int n,int a=1,int b=1){
return n>1 ? b+Sum_Fib(n-1,b,a+b) : 1;
}
int main(int argc,char *argv[]){
printf("SUMF(35) = %d\n",Sum_Fib(35));
return 0;
#include <stdio.h>
int n,s=0,a[36]={0,1,1};
void sum_f(int k)
{if(k>2)a[k]=a[k-1]+a[k-2];
s+=a[k];
if(k<n)sum_f(k+1);
return;
int main()
{ scanf("%d",&n);
sum_f(1);
printf("%d\n",s);