-
Notifications
You must be signed in to change notification settings - Fork 0
/
027.go
46 lines (41 loc) · 802 Bytes
/
027.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
import (
"fmt"
"./lib"
)
func getPrimeCount(a, b int) int {
pc := 0
poly := func (n int) int {
return n*n+a*n+b
}
for n := 0; ; n++ {
pn := poly(n)
if !lib.IsPrime(pn) {
break
}
pc++
}
return pc
}
func main() {
lpc := 0
lm := 0
for a := -1001; a < 1000; a++ {
if a % 2 == 0 {
// a must be odd
continue
}
for b := -1001; b < 1000; b++ {
if !lib.IsPrime(b) {
// b must be prime, so we can skip
continue
}
pc := getPrimeCount(a, b)
if pc > lpc {
lpc = pc
lm = a*b
}
}
}
fmt.Printf("Result: %d\n", lm)
}