Created
April 15, 2016 11:10
-
-
Save AhnMo/239d335c76569a70dc48aee6aafc80ee to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// lavida.us 1723 | |
#include <stdio.h> | |
unsigned long long int cache[91]; | |
unsigned long long int fibo(int n) { | |
int a; | |
if (cache[n] != 0) return cache[n]; | |
cache[n] = (n == 0 || n == 1)? n: fibo(n - 2) + fibo(n - 1); | |
return cache[n]; | |
} | |
int main(int argc, char **argv) { | |
int n, i; | |
scanf("%d", &n); | |
for (i = n - 1; i >= 0; --i) | |
printf("%llu\n", fibo(i)); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment