CodeTestValidate

No installations needed! Write Python directly in your browser and get instant feedback with our smart validation system.

Challenge # 3

Fibonacci Sequence Generator

Objective

Generate the Fibonacci sequence up to a given number of terms.

Instructions

  • You are given an integer variable n.

  • The Fibonacci sequence starts with 0 and 1, and each next number is the sum of the previous two.

  • Generate and print the first n terms of the Fibonacci sequence.

  • Print each term on the same line separated by a space.

Constraints:
Do not use input(). • `n` will be a non-negative integer.
Exemple IO

Input: n = 5

Output: 0 1 1 2 3

Input: n = 1

Output: 0

Input: n = 0

Output:

Try It Online!

Output:

Validate Your Results

Get your code reviewed and validated to understand what you did right and where you can improve.

Previous challengeGCD Calculator using Euclid’s AlgorithmNext challengeSum of All Numbers in a List
Loading...