Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Print Fibonacci Digits

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

Your question is Print Fibonacci Digits. 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

A Masimo patient-monitoring component needs a small Fibonacci sequence for a diagnostic display. Given a non-negative integer n, generate the first n Fibonacci terms, beginning with 0, 1.

Implement fibonacci_terms(n) and return the sequence as a Python list. The caller may print the returned list. Do not use recursion as the primary approach.

Formal Specification

  • Input: An integer n representing the number of Fibonacci terms to generate.
  • Output: A list containing exactly n integers, where each term after the first two equals the sum of the previous two terms.
  • The sequence is defined as F(0) = 0, F(1) = 1.

Constraints

  • 0 <= n <= 30
  • n is an integer
  • The output contains exactly n terms
  • The sequence begins with F(0) = 0 and F(1) = 1

Function Signature

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