Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Prime and Fibonacci Coding
00:00
5 left

Prime and Fibonacci Coding

MediumPython

Problem

UST QA automation utilities need deterministic numeric datasets for validating boundary conditions and performance. Implement a function that returns every prime number up to an inclusive limit and the first count Fibonacci numbers modulo 1_000_000_007.

Use an efficient odd-only Sieve of Eratosthenes for prime generation. The Fibonacci sequence begins with 0, 1, so the first count values are F(0) through F(count - 1).

Formal Specification

Implement generate_sequences(limit, count).

  • Input: limit, an integer defining the inclusive upper bound for prime search, and count, an integer defining the number of Fibonacci values.
  • Output: A dictionary with two keys:
    • primes: a list of all primes in ascending order from 2 through limit.
    • fibonacci: a list of count integers, where each value is F(i) % 1_000_000_007.

Constraints

  • 1 <= limit <= 10^7
  • 0 <= count <= 10^6
  • Fibonacci values are returned modulo 1,000,000,007
  • Prime values are returned in ascending order

Function Signature

def generate_sequences(limit, count):
Interviewer

Your question is Prime and Fibonacci Coding. 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
Sign up free to run your codeLog inLn 2
Run your code to see test output here.