Blum integer: Difference between revisions

Added Go
(→‎{{header|C}}: Removed superfluous code.)
(Added Go)
Line 91:
}
return 0;
}</syntaxhighlight>
 
{{out}}
<pre>
Same as Wren example.
</pre>
 
=={{header|Go}}==
{{trans|Wren}}
{{libheader|Go-rcu}}
<syntaxhighlight lang="go">package main
 
import (
"fmt"
"rcu"
)
 
func main() {
blum := make([]int, 50)
bc := 0
counts := make([]int, 4)
i := 1
for {
f := rcu.PrimeFactors(i)
if len(f) == 2 && f[0] != f[1] && f[0]%4 == 3 && f[1]%4 == 3 {
if bc < 50 {
blum[bc] = i
}
counts[i%10/3]++
bc++
if bc == 50 {
fmt.Println("First 50 Blum integers:")
rcu.PrintTable(blum, 10, 3, false)
fmt.Println()
} else if bc == 26828 || bc%100000 == 0 {
fmt.Printf("The %7sth Blum integer is: %9s\n", rcu.Commatize(bc), rcu.Commatize(i))
if bc == 400000 {
fmt.Println("\n% distribution of the first 400,000 Blum integers:")
for j := 0; j < 4; j++ {
fmt.Printf(" %6.3f%% end in %d\n", float64(counts[j])/4000, j)
}
return
}
}
}
if i%5 == 3 {
i += 4
} else {
i += 2
}
}
}</syntaxhighlight>
 
9,488

edits