# Finding prime number with Square root

Discussion in 'School Work Help' started by Flames, Mar 12, 2009.

1. ### Flames Out of Date User

5,151
432
25
Finding prime number with Square root is it possible? Got it in my programming assignment

#1

237
41
0
3. ### Flames Out of Date User

5,151
432
25
nw solved it already hahahaha I can't do that in C++ ln functions...=="

#3
4. ### iiimj4everiii Well-Known Member

211
241
0
No prime number needs to be a whole number. If sqrt(n) is a whole number m, then n = m². n, therefore is not a prime number. m doesn't have to be prime number because m can be any numbers, prime or not prime, real or imaginary to satisfy the equation m² = n or m = sqrt(n).

5. ### spider-man Well-Known Member

466
55
1

Wait iiimj4everiii, it won't work if someone input n = 10, 8, 12, 14, 20...

#5
Last edited: Feb 5, 2010
6. ### spider-man Well-Known Member

466
55
1
You cannot use the square root to determine if it's a prime number or not. The square root only only used for the limit number factor of the number that the person inputted.

For example:

input = 100
10 = sqrt of 100

for(int i=2; i<=10; i++)
{
// check if i is one of the factors of the input number.
}

THIS IS THE CORRECT WAY.

7. ### iiimj4everiii Well-Known Member

211
241
0
again: No prime number needs to be a whole number. If sqrt(n) is a whole number m, then n = m². n, therefore is not a prime number. m doesn't have to be prime number because m can be any numbers, prime or not prime, real or imaginary to satisfy the equation m² = n or m = sqrt(n).

8. ### spider-man Well-Known Member

466
55
1

Interesting, I get it now. I'm going to try it out. Thanks.