c - How would I properly make this loop display the first 40 digits of the fibonacci sequence? -
As far as I can tell, it seems that it should work.
The first two elements are set to 1 (I'm ignoring the first 0). Loop is considered to be loop through the array, and since Fibonacci numbers are equal to the sum of two preceding numbers, I want to add them, then they have to display them.
The output is all 2s, and I'm pretty sure why not.
Note: I am not looking for direct answers, but there is a way that I can understand myself.
// Fibonacci sequence #include & lt; Stdio.h & gt; Int main (zero) {int fib_numbers [40] = {1, 1}, i; For (i = 1; i & lt; 40; i ++) {Fib_translation [i] = fib_scrime [i] + fib_nug [ii]; Printf ("\ t% d \ n", phib_genement [i]); } Return 0; }
after the first step, the wrong element is 0 (not initial, but 0 in this matter). FAB [I + 1] = FAB [I] + FIB [I-1] is about; Printf ("% d \ n", fb [i + 1])? And of course, Phib should have 41 shapes instead of 40.
Comments
Post a Comment