3 divisors

Revision en2, by PolokN, 2018-06-23 01:58:15

Suppose you need to find out which number has three divisors including itself and 1. For getting these numbers you don't need to check the divisors of that number. A number has 3 divisors if it is a square of a prime number. For example 4 is a square of prime number 2. Here 4 has 3 divisors. 1,2,4. The reason is the square of a prime number is divisible by 1 , the number itself, and the square root of that number that is a prime number. So if you need to find out the numbers that have 3 divisors only and you have time complexity matter then just generate the prime numbers using sieve method. After that just check whether the given number's square root is equal to any prime number or not. Hope this will help you.

Tags #primes, divisors

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English PolokN 2018-06-23 01:58:15 16
en1 English PolokN 2018-06-23 01:37:07 727 Initial revision (published)