Challenge: Finding Fibonacci Numbers with Slices

This lesson brings you a challenge to solve.

Problem statement

In the last challenge you calculated Fibonacci numbers with arrays. Now, write a program in which main calls a function with the number of terms in the series n as a parameter. The function returns a slice with the Fibonacci numbers up to that number n, assuming n is greater than 00.

Input

A positive integer

Sample input

5

Output

A slice

Sample output

[0 1 1 2 3]

Try to implement the function below. Feel free to view the solution, after giving some shots. Good Luck!

Get hands-on with 1200+ tech skills courses.