-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
30 lines (24 loc) · 902 Bytes
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <bigint.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
int main() {
int i, f;
for (f = 1; f < 101; f++) {
bigint_t a = new_bigint(0); //create new bigintegers 0 and 1
bigint_t b = new_bigint(1);
bigint_t fib = new_bigint(1);
for (i = 1; i < f; i++) {
fib = allocateBigInt(); //need to allocate memory for a new biginteger otherwise string will be concatenate to previous char
if(add(fib, a, b)) break;
a = b; //equalling address of b to a
b = fib; //equalling address of fib to b
}
printf("%3d the Fib is ", f);
show_bigint(fib); //displaying biginteger
free_bigint(a); //freeing bigintegers
free_bigint(b);
free_bigint(fib);
}
return 0;
}