#include <stdio.h>
/* int fibonacci(int n)
{
if (n <= 2 && n >= 1)
return 1;
else
return fibonacci(n - 1) + fibonacci(n - 2);
}
*/
int fibonacci(int n)
{
int a = 1;
int b = 1;
int c = 1;
/* int c = 0;
if (n >= 1 && n <= 2)
return 1; */
while (n > 2)
{
c =a + b;
a = b;
b = c;
n--;
}
return c;
}
int main()
{
//斐波那契算法
int n = 0;
printf("请输入一个数字1~30:>");
scanf( "% d ", &n );
return 1;
int res = fibonacci(n);
printf("%d\n", res);
return 0;
}