Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Prime Divisors and Fibonacci

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

Your question is Prime Divisors and Fibonacci. 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

Bloomberg Industry Group services may need compact numeric summaries for validation and analysis. Given an integer n and a nonnegative integer k, return its distinct prime divisors in ascending order and the first k values of the Fibonacci sequence.

Use the Fibonacci definition F(0) = 0, F(1) = 1, and F(i) = F(i - 1) + F(i - 2). The prime-divisor list must contain each divisor once, even when a prime divides n multiple times.

Formal Specification

Implement generate_number_summary(n, k).

  • Input: n, an integer at least 2, and k, an integer at least 0.
  • Output: a dictionary with two keys: prime_divisors, containing an ascending list of distinct prime divisors of n, and fibonacci, containing the first k Fibonacci numbers.

Constraints

  • 2 <= n <= 10^12
  • 0 <= k <= 100,000
  • Prime divisors must be distinct and sorted in ascending order
  • The Fibonacci sequence begins with 0, 1
  • External libraries are not allowed

Function Signature

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