forked from TEX/lab3_test
aye
This commit is contained in:
28
fibonacci.c
Normal file
28
fibonacci.c
Normal file
@@ -0,0 +1,28 @@
|
||||
#include <stdio.h>
|
||||
int main() {
|
||||
|
||||
int i, n;
|
||||
|
||||
int t1 = 0, t2 = 1;
|
||||
|
||||
int next = t1 + t2;
|
||||
|
||||
printf("kol-vo: ");
|
||||
scanf("%d", &n);
|
||||
|
||||
printf("Fibonaci: %d, %d, ", t1, t2);
|
||||
|
||||
for (i = 3; i <= n; ++i) {
|
||||
printf("%d, ", next);
|
||||
t1 = t2;
|
||||
t2 = next;
|
||||
next = t1 + t2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user