Dsa
Math
Easy
Fibonacci Sequence Generator
Write a program that generates the Fibonacci sequence up to the nth term (inclusive).
Input Format:
- A single integer n (1 ≤ n ≤ 30).
Output Format:
- Print the Fibonacci numbers separated by spaces.
Example:
Input:
5
Output:
0 1 1 2 3 5
Key concepts
fibonaccisequenceiteration
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now