FastPrepFactor Combinations
Problems/Factor Combinations

Factor Combinations

Bloomberg LP logoBloomberg LP● MediumNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Bloomberg new grad onsite interview. The report gives only N and asks for all combinations whose product is N. On page 2 the author fixes the range of factors to 2 through N, and a reply names a well-known problem. Our version keeps the standard factor-combination task.

Given an integer n, return every unique combination of integers from 2 through n whose product is n. Do not include [n] by itself.

Write the factors in each combination from smallest to largest (equal factors may repeat). Return the combinations in lexicographic order: compare two combinations factor by factor from the left, and the one with the first smaller factor comes first.

Function

getFactors(n: int) → int[][]

Examples

Example 1

n = 12return = [[2,2,3],[2,6],[3,4]]

The three ways to write 12 as a product of at least two factors, smallest first, are 2×2×3, 2×6, and 3×4.

Example 2

n = 16return = [[2,2,2,2],[2,2,4],[2,8],[4,4]]

Each combination appears once, with its factors sorted from smallest to largest. A reordering of the same factors is not listed again.

Example 3

n = 37return = []

The input is prime, so its only factorization is the number by itself. That one is excluded, so the answer is empty.

Constraints

  • 2 <= n <= 10000000.
  • Every returned factor is between 2 and n - 1.
  • The total result fits in memory.

More Bloomberg LP Onsite Interview questions

  • Pascal's TrianglePHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
  • Valid Triangle NumberPHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
  • Collatz Conjecture with Shared MemoizationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Top K Frequent WordsONSITE INTERVIEW · Seen Nov 2026
  • Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Factor CombinationsLinkedIn · PHONE SCREENLinkedIn interview questions
  • Word SearchAmazon · ONSITE INTERVIEW
  • Park Train Cars by PreferenceMercor · ONSITE INTERVIEWMercor interview questions
  • Word SearchMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Enumerate Character Paths to a MarkerTesla · ONSITE INTERVIEWTesla interview questions
  • Next Greater Numerically Balanced NumberGoogle · ONSITE INTERVIEWGoogle interview questions
  • Trace a Word Through a Letter GridExpedia · ONSITE INTERVIEWExpedia interview questions
  • Find a Word in a Letter GridMeta · ONSITE INTERVIEWMeta interview questions
  • Count Components With a Prime Total ValueNutanix · ONSITE INTERVIEWNutanix interview questions
  • All Balanced Strings from Minimum Parenthesis InsertionsRubrik · ONSITE INTERVIEWRubrik interview questions

Bloomberg LP interview experiences

  • Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
  • Bloomberg SWE Intern Interview Questions: 68 Questions
  • Bloomberg Interview Questions, Level Not Reported: 65 Questions
  • Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
  • Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
  • Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)
All Bloomberg LP interview questionsSee Bloomberg LP hiring insights
Saved
class Solution {
    public int[][] getFactors(int n) {
        // Write your code here.
    }

}
Checking account…