c#中求斐波那契数列第十项

c#中求斐波那契数列第十项
2025-04-05 08:39:38
推荐回答(1个)
回答(1):

int a = 1;
int b = 1;
int count = 0;
int count1 = 0;
while (count1<20)
{
count1++;
int temp = a;
if (count1==10)
{
Console.WriteLine(temp);
break;
}
// count += temp;
a = b;
b = temp + b;
}
可以输出 第10 个数的值