#include <stdio.h>
int fun(int t) {
int i, f0 = 0, f1 = 1, f2 = f0 + f1;
while (f2 <= t) {
f0 = f1;
f1 = f2;
f2 = f0 + f1;
}
return f2;
}
void main() {
int n;
scanf("%d", &n);
printf("%d", fun(n));
}
编写函数fun功能是:求Fibonacci数列中大于t的最小的一个数,结果由函数返回。例如:当t=1000时,函数值为:1597。
猜你喜欢
转载自blog.csdn.net/qq_38490457/article/details/106107383
今日推荐
周排行