斐波那契数列指的是这样一个数列:1,1,2,3,5,8,13,21,34,55,89...
这个数列从第3项开始,每一项都等于前两项之和。
这个数列从第3项开始,每一项都等于前两项之和。
a1=1,a2=1,an=an-1+an-2(n>=3)#include <stdio.h> long act(long count, long limit, long n1, long n2, long n3) { n3 = n1 + n2; n1 = n2; n2 = n3; count++; if (count < limit) { n3 = act(count, limit, n1, n2, n3); } return n3; } int main() { long n1, n2, n3; long count = 2; long limit; n1 = 1; n2 = 1; n3 = 1; scanf("%ld", &limit); n3 = act(count, limit, n1, n2, n3); printf("%ld", n3); return 0; }
当项数大于65时因为数据过大无法计算
标签:count,数列,波拉,long,limit,n1,n2,n3 From: https://www.cnblogs.com/hehuanwu4714/p/16770980.html