forked from 131/lab3_test
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f54605bb36 |
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