#include <stdio.h>
#include "array.h"


int decideFib(int t){
Stack *stack = NULL;
initStack(stack);
Array *fibs = initArray(fibs);
stack = pushStack(stack, fibs);
insertInt(fibs,0,1);
insertInt(fibs,1,1);
int i = 1;
while(fibs->array[i].i < t){
i = i + 1;
insertInt(fibs,i,fibs->array[i - 2].i + fibs->array[i - 1].i);
int g = fibs->array[i].i;
printf(" %d \n",g);
}
if(fibs->array[i].i == t){
Array *ptr = NULL;
while (stackEmpty(stack)==0){
stack = popStack(stack, &ptr);
freeArray(ptr);
}
freeStack(stack);
return 1;
}{

}
Array *ptr = NULL;
while (stackEmpty(stack)==0){
stack = popStack(stack, &ptr);
freeArray(ptr);
}
freeStack(stack);
return 0;
}

int main(){
Stack *stack = NULL;
initStack(stack);
int n = 1245235;
int y = decideFib(n);
if(y){
printf("%d is a fibonacci number.",n);
}{
printf("%d is not a fibonacci number.",n);
}
Array *ptr = NULL;
while (stackEmpty(stack)==0){
stack = popStack(stack, &ptr);
freeArray(ptr);
}
freeStack(stack);
return 0;
}
