Erdős-primes: Difference between revisions
→{{header|Go}}: Updated in line with Wren example of which it is a translation.
(→{{header|Wren}}: Further speed-up.) |
(→{{header|Go}}: Updated in line with Wren example of which it is a translation.) |
||
Line 718:
=={{header|Go}}==
{{trans|Wren}}
{{libheader|Go-rcu}}
<syntaxhighlight lang="go">package main
import
)
c[0] = true▼
c[i] = true▼
▲ }
▲ for {
p2 := p * p▼
break▼
func main() {
limit := int(1e6)
c := rcu.PrimeSieve(limit-1, true)
var erdos []int
lastErdos := 0
for i := 2; i < limit; {
if !c[i] {
Line 781 ⟶ 745:
}
if found {
}
}
Line 790 ⟶ 758:
}
}
fmt.Printf("The %d Erdős primes under %s are\n", len(
rcu.PrintTable(erdos, 10, 6, false)
fmt.Printf("
▲ erdosLower = append(erdosLower, e)
▲ fmt.Printf("The %d Erdős primes under %s are\n", len(erdosLower), commatize(lowerLimit))
▲ fmt.Printf("\n\nThe %s Erdős prime is %s.\n", commatize(show), commatize(erdos[show-1]))
}</syntaxhighlight>
Line 813 ⟶ 766:
<pre>
The 25 Erdős primes under 2,500 are
2 101 211 367 409 419 461 557 673 709
769 937 967 1009 1201 1259 1709 1831 1889 2141
2221 2309 2351 2411 2437
The 7,875 Erdős prime is 999,721.
|