We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 10b52c2 commit 9245e64Copy full SHA for 9245e64
utils/utils.go
@@ -4,8 +4,11 @@ import "math"
4
5
func IsPrime(num int) bool {
6
floatNum := float64(num)
7
- for i := 2; i <= int(math.Floor(math.Sqrt(floatNum))); i++ {
8
- if num%i == 0 {
+ if (num%2 == 0) || (num%3 == 0) {
+ return false
9
+ }
10
+ for i := 1; (6*i - 1) <= int(math.Floor(math.Sqrt(floatNum))); i++ {
11
+ if num%(6*i-1) == 0 || num%(6*i+1) == 0 {
12
return false
13
}
14
0 commit comments