斐波那契数列前20项的代码
时间: 2023-11-17 10:07:24 浏览: 74
斐波那契数列(前100项).rar
以下是斐波那契数列前20项的代码:
```
#include <stdio.h>
int main()
{
int n, first = 0, second = 1, next;
printf("Enter the number of terms: ");
scanf("%d",&n);
printf("Fibonacci Series: ");
for (int i = 0; i < n; i++)
{
if (i <= 1)
next = i;
else
{
next = first + second;
first = second;
second = next;
}
printf("%d ",next);
}
return 0;
}
```
请问还有什么我可以帮您的吗?
阅读全文