FunctionRacerProblemsRace

Prime Factorization

EasyMathPython, JavaScript, TypeScript, Java, C++

Return the prime factors of n in increasing order, repeating a prime as many times as it divides n. For n = 1 return an empty list.

Example 1

n 12
returns [2,2,3]

12 = 2 * 2 * 3.

Example 2

n 29
returns [29]

29 is prime.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Math problems