Primality test
Go Algorithms
loop with early return
Flowchart (ISO 5807)
Source code
func isPrime(n int) bool {
if n < 2 {
return false
}
for i := 2; i*i <= n; i++ {
if n%i == 0 {
return false
}
}
return true
}