3 divisors

Правка en1, от PolokN, 2018-06-23 01:37:07

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 is a square root of any prime number or not. Hope this will help you.

Теги #primes, divisors

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский PolokN 2018-06-23 01:58:15 16
en1 Английский PolokN 2018-06-23 01:37:07 727 Initial revision (published)