Dsa
Math
Medium
Count Distinct Prime Factors
Given an integer n, calculate how many distinct prime factors it has.
For example, given the input:
28
The output should be:
2 (because the distinct prime factors of 28 are 2 and 7).
Input format:
- A single integer n (2 ≤ n ≤ 10^6).
Output format:
- A single integer representing the count of distinct prime factors of n.
Key concepts
mathprimefactorization
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now