FunctionRacerProblemsRace

Distinct Prime Factors

EasyMathPython, JavaScript, TypeScript, Java, C++

Return how many different prime numbers divide n. For example 12 = 2 * 2 * 3 has two different primes. For n = 1 return 0.

Example 1

n 12
returns 2

The primes are 2 and 3.

Example 2

n 49
returns 1

Only 7.

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