Skip to content

Instantly share code, notes, and snippets.

@asmuth
Created April 2, 2012 20:12
Show Gist options
  • Save asmuth/2286897 to your computer and use it in GitHub Desktop.
Save asmuth/2286897 to your computer and use it in GitHub Desktop.
smallest fibonacci sequence longer than 10 chars...
#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