Jump to content

Untouchable numbers: Difference between revisions

→‎{{header|Go}}: Reverted to a limit of 100,000 as 1 million figure was miles out!
(→‎{{header|Go}}: Reverted to a limit of 100,000 as 1 million figure was miles out!)
Line 63:
 
=={{header|Go}}==
{{incorrect|Go|sorry, 150,232 not that +20}}
{{trans|Wren}}
... but now goes up to 1,000,000 as I'm reasonably sure (see talk page) that the figure obtained is correct.
<lang go>package main
 
Line 139 ⟶ 137:
 
func main() {
limit := 1000000100000
s := sieve(2014 * limit)
untouchable := []int{2, 5}
for n := 6; n <= limit; n += 2 {
Line 156 ⟶ 154:
count++
}
fmt.Printf("\n\n%7s6s untouchable numbers were found <= 2,000\n", commatize(count))
p := 10
count = 0
Line 164 ⟶ 162:
cc := commatize(count - 1)
cp := commatize(p)
fmt.Printf("%7s6s untouchable numbers were found <= %9s7s\n", cc, cp)
p = p * 10
if p == limit {
Line 173 ⟶ 171:
cu := commatize(len(untouchable))
cl := commatize(limit)
fmt.Printf("%7s6s untouchable numbers were found <= %s\n", cu, cl)
}</lang>
 
Line 200 ⟶ 198:
1,958 1,960 1,962 1,972 1,986 1,992
 
196 untouchable numbers were found <= 2,000
2 untouchable numbers were found <= 10
5 untouchable numbers were found <= 100
89 untouchable numbers were found <= 1,000
1,212 untouchable numbers were found <= 10,000
13,863 untouchable numbers were found <= 100,000
150,252 untouchable numbers were found <= 1,000,000
</pre>
 
9,490

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.