Fibonacci Sequence

Number Theory Level pending

1, 1, 2, 3, 5, 8, 13, 21, 34, ...

What is the 159th number in this sequence?


The answer is 757791618667731139247631372100066.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Dilip Singh
Nov 26, 2014

int bigFibo(int term) { int num1[100]; int num2[100]; int temp[100]; int counter = 0; int i = 0; int digit = 0; int carry = 0; int val = 0;

for(i = 0; i < 100; )
{
    num1[i] = 0;
    num2[i] = 0;
    temp[i] = 0;
    i++;
}

counter = 2;

num1[99] = 1;
num2[99] = 1;
while(counter < term)
{
    i = 99;
    //get sum of last two terms
    while(i >= 0)
    {
        if(carry + num1[i] + num2[i] > 10)
        {
            if((i - 1) < 0)
            {
                printf("\nSorry, the specified term is beyond the limit of this function!");
                return 0;
            }
        }
        val = carry + num1[i] + num2[i];
        digit = val % 10;
        carry = (val - (val % 10)) / 10;
        temp[i] = digit;
        temp[i - 1] = carry;
        i--;
    }

    i = 99;

    while(i >= 0)
    {
        num1[i] = num2[i];
        num2[i] = temp[i];
        i--;
    }
    counter++;
    printf("\nTerm %d: ", counter);
    i = 0;
    int begin = 0;
    while(i < 100)
    {
        if(temp[i])
        {
            begin = 1;
        }
        if(begin)
        {
            printf("%d", temp[i]);
        }
        i++;
    }
}

}

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...