Ormiston triples: Difference between revisions
→{{header|Go}}: Doh, what a silly mistake!
(Add Python) |
(→{{header|Go}}: Doh, what a silly mistake!) |
||
Line 114:
</pre>
=={{header|Go}}==
{{trans|Wren}}
{{libheader|Go-rcu}}
This runs in about 54 seconds on my Core i7 machine.
<syntaxhighlight lang="go">
import (
var limit = 1e10▼
"fmt"
"rcu"
)
var j = 1e9▼
var count = 0▼
func main() {
var
if ((p2 - p1) % 18 != 0 || (p3 - p2) % 18 != 0) continue▼
var
for
var key3 = 1▼
if (key2 == key3) {▼
if (count < 25) orm25.add(p1)▼
if (p1 >= j) {▼
counts.add(count)▼
j = j * 10▼
}
for _, dig := range rcu.Digits(p1, 10) {
key1 *= primes[dig]
key2 := 1
for _, dig := range rcu.Digits(p2, 10) {
key2 *= primes[dig]
}
if key1 != key2 {
continue
}
for _, dig := range rcu.Digits(p3, 10) {
key3 *= primes[dig]
}
orm25 = append(orm25, p1)
}
counts = append(counts, count)
}
}
}
counts = append(counts, count)
for i := 0; i < 25; i++ {
fmt.Printf("%8v ", orm25[i])
if (i+1)%5 == 0 {
fmt.Println()
}
}
fmt.Println()
for i := 0; i < len(counts); i++ {
j *= 10
fmt.Println()
}
▲System.print("Smallest members of first 25 Ormiston triples:")
▲ Fmt.print("$,d Ormiston triples before $,d", counts[i], j)
▲ j = j * 10
}</syntaxhighlight>
|