#include "stdio.h"
int F(int n);
int SUM(int n);
int main(){
int n,number,a;
scanf("%d",&n);
while(n!=0){
number=SUM(n);
printf("%d\n",number+1);
scanf("%d",&n);
}
return 0;
}
int F(int n){
if(n<4 && 1<n)
return 1;
else if(n==1)
return 0;
else if(n>=4)
return (F(n-1)+F(n-3));
}
int SUM(int n){
int sum=0;
int i,t;
t=n;
for(i=0;i<n;i++,t--){
sum+=F(t);
}
return sum;
}
原文:http://www.cnblogs.com/sureli/p/5090337.html