#include<stdio.h>
int fib(int n) {
int a = 1;
int b = 1;
int c = 1;
while (n > 2) {
c = a + b;
a = b;
b = c;
n--;
}return c;
}
int main() {
int ret;
int n;
scanf_s("%d", &n);
ret = fib(n);
printf("%d", ret);
return 0;
}
斐波那契数列(优化)
最新推荐文章于 2024-10-09 22:28:58 发布