MIPI_BaseC_WebinarFRTK/05_Lecture05/13_fibonacci_p40.c

24 lines
412 B
C
Raw Permalink Normal View History

2024-11-13 09:22:28 +03:00
#include <stdio.h>
int main( void )
{
unsigned int n, i, f1, f2, m;
scanf("%d", &n);
f1 = 1;
f2 = 1;
if (n == 1)
printf("1");
else
if (n != 0)
{
printf("1 1 ");
for (i = 2; i < n; ++i){
m = f1 + f2;
f1 = f2;
f2 = m;
printf("%u ", f2);
}
}
return 0;
}