-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Open
Description
Think this primality test should be simplified. You may use the following algorithm:
// 2 is a special case of prime, and if n < 2 then skip it. For others see bellow
if n > 2 {
for i := 2; i <= i/2; i++ {
if n % i == 0 {
break
//It's not a prime
}
}
// It's a prime
}
I am referring to the simplification of the following part of the code:
for i, w := 5, 2; i*i <= n; { |
Metadata
Metadata
Assignees
Labels
No labels