Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Fibonacci Series Function

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Fibonacci Series Function. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Zen Technologies simulation software needs a predictable numeric training sequence. Write a function that returns the first n numbers in the Fibonacci sequence, starting with 0 and 1.

Each subsequent number is the sum of the previous two numbers. Return the sequence as a Python list. If n is 0, return an empty list.

Formal Specification

  • Input: An integer n, representing the number of Fibonacci values to generate.
  • Output: A list containing exactly n integers in Fibonacci order.
  • The sequence begins 0, 1, 1, 2, 3, 5, ....
  • The function should return values rather than print them, so the result can be used by other Zen Technologies training components.

Constraints

  • 0 <= n <= 30
  • Return exactly n values
  • The sequence starts with 0 and 1
  • Use integer arithmetic only

Function Signature

def fibonacci_series(n):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output