Given a number n, return an array containing the first n Fibonacci numbers.…
PYQ Accenture Hiring Assessment 2024
Given a number n, return an array containing the first n Fibonacci numbers.
Note: The first two numbers of the series are 0 and 1.
Input format
A single line containing one integer n.
Output format
Print the first n Fibonacci numbers on one line, separated by single spaces.
Examples
Input | Output |
|---|---|
5 | 0 1 1 2 3 |
7 | 0 1 1 2 3 5 8 |
2 | 0 1 |
Constraints
1 <= n <= 30
Attempted by 1 students.
Sign up free to check your answer
Sign up freeLoading lesson…

