Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Do-While Fibonacci Series

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

Your question is Do-While Fibonacci Series. 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

Print the Fibonacci series using a do-while loop.

Implement the function below to return the first n Fibonacci numbers, starting with 0, 1. Python has no native do-while statement, so emulate its behavior with while True and an explicit termination check.

Contract

n is an integer. Return a list containing exactly n Fibonacci numbers. Return an empty list when n is 0.

Constraints

  • 0 <= n <= 1000
  • The sequence starts with 0 and 1
  • Return exactly n values

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