Skip to content

Instantly share code, notes, and snippets.

@AhnMo
Created April 15, 2016 11:10
Show Gist options
  • Save AhnMo/239d335c76569a70dc48aee6aafc80ee to your computer and use it in GitHub Desktop.
Save AhnMo/239d335c76569a70dc48aee6aafc80ee to your computer and use it in GitHub Desktop.
// 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