4 ms·
I (surprisingly) could not get it to generate a Fibonacci function that skips 5.
by wilg 4y ago
I (surprisingly) could not get it to generate a Fibonacci function that skips 5.
- thewebcount 4y agoAs a human, I’m having trouble understanding the problem description. What does it mean to “skip 5”? I’ve always understood the definition of a Fibonacci sequence to be, starting with 2 numbers (usually 1 and 1) the next number in the sequence is the sum of the previous 2. So starting with 1 and 1, we get 2. 2 and 1 is three. 3 and 2 is five. What do we do from here? Do I not add 5 and 3? If not, then what do I add? 3 and 2 again? Do I repeat 3 and get 6? What does it mean to “skip 5”?
- fantispug 4y agoWith the prompt // Print the fibonnaci sequence, except the number 5. int main() { I got the result: int a = 0; int b = 1; int c = 0; while (c < 100) { c = a + b; a = b; b = c; if (c != 5) { cout << c << endl; } } return 0;