Fibonacci Sequence
Fibonacci Sequence
EasyLoops12% accepted
The Fibonacci sequence starts with 0 and 1, and each subsequent number is the sum of the two before it: 0, 1, 1, 2, 3, 5, 8, 13, 21, ... Given N, print the first N Fibonacci numbers separated by spaces. This classic sequence appears in nature, art, and algorithm design. Return the Nth Fibonacci number (F1 = 0, F2 = 1, F3 = 1, ...).
Approach
Given N, print the first N Fibonacci numbers separated by spaces (starting from 0).
Input
1
Output
0
More Loops problems
Browse all coding problems →solution.py
Loading editor...
Test 1
Test 2
Test 3
Press Run to test your custom input, or Submit to judge against all test cases.
Sign in to continue
Create a free account to run code, submit solutions and track progress.
- Free forever — no credit card
- 10+ languages with live execution
- Points, streaks & leaderboards