Question: Primality Testing??

I am trying to code a naive method for checking if a number is prime. where it checks if a number is prime by checking if a number 'k' divdes into n.

 

This is what i have done so far but it dosen't seem to be working properly any help would be greatly appriciated?


restart:
NaivePrimetest:=proc(n)
local t,k,prime:
prime:=true:
for k from 2 to (n)^1/2 do
t:=gcd(k,n):
if t > 1 then
prime:=false:
printf("%a is not a prime",n):

fi:
od:
printf("%a is probably a prime",n):
end proc:

 

Thanx

Please Wait...