fibonaci numbers

what's the simplest way of getting the sequence?


  • The simplest way that I came up with is to initialize the first 2 ints in the array to 1, and then run a loop from 2 to the number of numbers you want to put in the sequence. In each iteration, assign num[count] to the sum of num[count-2] and num[count-1], like so...

    num[0] = 1;

    num[1] = 1;

    for (count = 2; count < 10; count++)

    num[count] = num[count-2] + num[count-2];

  • In the example 10 would be the amount of numbers.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!