Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Writing Fibonacci Function
00:00
5 left

Writing Fibonacci Function

EasyPython

Problem

State Street analytics workflows may use Fibonacci-like sequences for testing numerical pipelines. Write a function that returns the first n numbers in the Fibonacci sequence.

Define the sequence as F(0) = 0, F(1) = 1, and F(k) = F(k - 1) + F(k - 2) for k >= 2.

Formal Specification

Given a non-negative integer n, return a list containing exactly the first n Fibonacci numbers, starting with F(0). For n = 0, return an empty list.

Constraints

  • 0 <= n <= 10^4
  • Return exactly n Fibonacci values
  • Use Python integers for the results

Function Signature

def fibonacci_sequence(n):
Interviewer

Your question is Writing Fibonacci Function. Start with the requirements in the Question tab.

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.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.