DLL
This commit is contained in:
parent
0b13972f36
commit
bd0893c21f
4 changed files with 100 additions and 35 deletions
31
test.c
31
test.c
|
|
@ -1,7 +1,8 @@
|
|||
#include <stdint.h>
|
||||
#include <gmp.h>
|
||||
|
||||
uint64_t fibonacci( void ) {
|
||||
const int n = 250000;
|
||||
const int n = 25000;
|
||||
uint64_t a = 0, b = 1, c;
|
||||
|
||||
for (int i = 2; i <= n; i++) {
|
||||
|
|
@ -11,4 +12,30 @@ uint64_t fibonacci( void ) {
|
|||
}
|
||||
|
||||
return b;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
char* fibonacci_gmp() {
|
||||
const int n = 25000;
|
||||
static char result[10000]; // Assicurati che sia abbastanza grande per contenere il numero
|
||||
mpz_t a, b, c;
|
||||
|
||||
mpz_init_set_ui(a, 0);
|
||||
mpz_init_set_ui(b, 1);
|
||||
mpz_init(c);
|
||||
|
||||
for (int i = 2; i <= n; i++) {
|
||||
mpz_add(c, a, b);
|
||||
mpz_set(a, b);
|
||||
mpz_set(b, c);
|
||||
}
|
||||
|
||||
mpz_get_str(result, 10, b);
|
||||
|
||||
mpz_clear(a);
|
||||
mpz_clear(b);
|
||||
mpz_clear(c);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue