Primality by trial division: Difference between revisions
Content deleted Content added
mNo edit summary |
No edit summary |
||
Line 2,371: | Line 2,371: | ||
func isPrime n |
func isPrime n |
||
flag = 1 |
|||
if n <= 1 return 0 ok |
|||
if n = 2 or n = 3 return 1 ok |
|||
if n % 2 = 0 return 0 ok |
|||
if n % 3 = 0 return 0 ok |
|||
i = 5 |
|||
w = 2 |
|||
while i * i <= n |
|||
if n % i = 0 return 0 ok |
|||
i = i + w |
|||
w = 6 - w |
|||
end return 1 |
|||
</lang> |
</lang> |
||