Ormiston triples: Difference between revisions
Content added Content deleted
(Add Python) |
(→{{header|Go}}: Doh, what a silly mistake!) |
||
Line 114: | Line 114: | ||
</pre> |
</pre> |
||
=={{header|Go}}== |
=={{header|Go}}== |
||
{{incorrect|Go|this is the Wren code}} |
|||
{{trans|Wren}} |
{{trans|Wren}} |
||
{{libheader|Go-rcu}} |
{{libheader|Go-rcu}} |
||
This runs in about 54 seconds on my Core i7 machine. |
This runs in about 54 seconds on my Core i7 machine. |
||
<syntaxhighlight lang="go"> |
<syntaxhighlight lang="go">package main |
||
import "./fmt" for Fmt |
|||
import ( |
|||
⚫ | |||
"fmt" |
|||
var primes = Int.segmentedSieve(limit, 8) |
|||
"rcu" |
|||
var orm25 = [] |
|||
) |
|||
⚫ | |||
⚫ | |||
func main() { |
|||
var counts = [] |
|||
⚫ | |||
for (i in 0...primes.count-2) { |
|||
primes := rcu.Primes(limit) |
|||
var |
var orm25 []int |
||
j := int(1e9) |
|||
⚫ | |||
⚫ | |||
var |
var counts []int |
||
for |
for i := 0; i < len(primes)-2; i++ { |
||
p1 := primes[i] |
|||
p2 := primes[i+1] |
|||
p3 := primes[i+2] |
|||
⚫ | |||
⚫ | |||
continue |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
} |
} |
||
key1 := 1 |
|||
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() |
|||
} |
} |
||
} |
|||
counts.add(count) |
|||
⚫ | |||
Fmt.tprint("$,10d ", orm25, 5) |
|||
System.print() |
|||
j = 1e9 |
|||
for (i in 0...counts.count) { |
|||
⚫ | |||
⚫ | |||
System.print() |
|||
}</syntaxhighlight> |
}</syntaxhighlight> |
||