MeetCode - Programming Platform | MeetCode - Programming Solutions Platform

Computer Mathematics Program to Count Distinct Prime Factors with Explanation

Computer Mathematics Medium Primes & Factorization 26 views
This problem helps you practice core Computer Mathematics fundamentals in a practical way. It builds intuition around count, distinct, prime. Let’s break it down step by step so you can implement it confidently.
Back to Questions

Problem Statement

Given n, print how many distinct primes divide it.

Input Format

One integer n.

Output Format

One integer count.

Constraints

2

Code Solution

This explanation is written for learning purposes and to help beginners understand the concept clearly.
Trial divide; when p divides, increment count and divide fully. If leftover>1 add 1.

Output Example

Input:
72
Output:
2

Common Mistakes

- Treating 1 as prime.
- Checking divisibility up to n instead of sqrt(n).
- Missing negative/zero inputs handling.

Notes & Extra Practice

Solutions (0)

No solutions submitted yet. Be the first!

Prev Next