← Back to Loops
Question 205
First Ten Fibonacci Numbers
First Ten Fibonacci Numbers
Write a program that prints the first 10 numbers of the Fibonacci sequence on a single line, separated by single spaces. The sequence starts with 0 and 1, and every number after that is the sum of the two before it: 0, 1, 1, 2, 3, 5, and so on. Keep track of the two most recent values as you loop. No input is needed.
Expected Output:
0 1 1 2 3 5 8 13 21 34= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
Loops
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (p, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.