31 lines
473 B
C
31 lines
473 B
C
#include <stdio.h>
|
|
|
|
int main(void) {
|
|
int fib;
|
|
printf("fib? fib! fib? ");
|
|
scanf("%d", &fib);
|
|
|
|
int current = 0;
|
|
int next = 1;
|
|
|
|
if (fib < 1) {
|
|
printf("Wait, wat?\n");
|
|
return 1;
|
|
}
|
|
|
|
if (fib == 1) {
|
|
printf("fib: %d\n", current);
|
|
return 0;
|
|
}
|
|
|
|
for (int i = 2; i < fib; ++i) {
|
|
int new = current + next;
|
|
current = next;
|
|
next = new;
|
|
}
|
|
|
|
printf("fib: %d\n", next);
|
|
|
|
return 0;
|
|
}
|