Prime numbers whose neighboring pairs are tetraprimes: Difference between revisions
Prime numbers whose neighboring pairs are tetraprimes (view source)
Revision as of 19:44, 27 June 2023
, 10 months ago→{{header|Go}}: Updated in line with Wren version of which it's a translation - about 5 times quicker than before.
(→{{header|C}}: Wasn't quite right before - hence problem with Wren alignment.) |
(→{{header|Go}}: Updated in line with Wren version of which it's a translation - about 5 times quicker than before.) |
||
Line 454:
)
func hasDups(pf []int) bool {▼
if le == 1 {▼
return false▼
for _, p :=
if p * p
if count == 4 || p == prevFact {
return false
count++
n /= p
prevFact = p
}
} else {
break
}
}
if count == 4 || n == prevFact {
▲ return false
▲ if pf[i] == value {
▲ return true
}
count++
}
return
}
// Note that 'gaps' will only contain even numbers here.
func median(gaps []int) int {
Line 487 ⟶ 494:
func main() {
▲ const LIMIT = int(1e7)
▲ primes := rcu.Primes(LIMIT)
highest5 := primes[sort.SearchInts(primes, int(1e5))-1]
highest6 := primes[sort.SearchInts(primes, int(1e6))-1]
Line 496 ⟶ 501:
j := 100_000
for _, p := range primes {
// process even numbers first as likely to have most factors
▲ if cond1 && cond2 {
tetras1 = append(tetras1, p)
if
sevens1++
}
}
▲ if cond3 && cond4 {
if isTetraPrime(p+1) && isTetraPrime(p+2) {
tetras2 = append(tetras2, p)
if
sevens2++
}
}
if p == highest5 || p == highest6 || p == highest7 {
for i := 0; i < 2; i++ {
|