Created
April 2, 2012 20:12
-
-
Save asmuth/2286897 to your computer and use it in GitHub Desktop.
smallest fibonacci sequence longer than 10 chars...
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
#include <stdio.h> | |
#include <string.h> | |
#define MIN_CHARS 10 | |
int main(char *argv, int argc){ | |
int i, m = 10, f[3] = {0,1}; | |
for(i = MIN_CHARS; i > 2; i--){ | |
m *= 10; | |
} | |
for(i = 0; f[0] < m; i++) { | |
f[2] = f[0] + f[1]; | |
memcpy(f, f + 1, sizeof(int) * 2); | |
} | |
printf("%i -> %i\n", i, f[0]); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment