Description: You are given a positive integer N. Your task is to generate and print the Fibonacci sequence up to N terms. Display all the terms in order on a single line, separated by spaces.
Example 1
Input: n = 5
Output: 0 1 1 2 3
Explanation: Not Needed
Example 2
Input: 7
Output: 0 1 1 2 3 5 8
Explanation: Not Needed
Approach, complexity and clean code in every language. Sign in to unlock the editorial.
Your submissions, results and runtime history live here. Sign in to start your streak.
2
0 1
5
0 1 1 2 3