Skip to content

Instantly share code, notes, and snippets.

@ikr7
Created December 15, 2015 13:47
Show Gist options
  • Save ikr7/a582046d90d611c1b2c8 to your computer and use it in GitHub Desktop.
Save ikr7/a582046d90d611c1b2c8 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <gmp.h>
#define N 100000
int main () {
int i = 0;
mpz_t fib, p, pp;
mpz_init_set_ui( fib, 1);
mpz_init_set_ui( p, 1);
mpz_init_set_ui(pp, 0);
while (N - 1 > i) {
mpz_add(fib, p, pp);
mpz_set(pp, p);
mpz_set( p, fib);
i++;
}
mpz_out_str(stdout, 10, fib);
mpz_clear(fib);
mpz_clear(p);
mpz_clear(pp);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment