Triplet of three numbers: Difference between revisions
Content added Content deleted
m (Removed useless space.) |
(Added Go) |
||
Line 602: | Line 602: | ||
..., 5653, [5654], __, __, 5657, __, 5659, ... |
..., 5653, [5654], __, __, 5657, __, 5659, ... |
||
..., 5737, [5738], __, __, 5741, __, 5743, ... |
..., 5737, [5738], __, __, 5741, __, 5743, ... |
||
</pre> |
|||
=={{header|Go}}== |
|||
{{trans|Wren}} |
|||
{{libheader|Go-rcu}} |
|||
<lang go>package main |
|||
import ( |
|||
"fmt" |
|||
"rcu" |
|||
) |
|||
func main() { |
|||
c := rcu.PrimeSieve(6003, false) |
|||
var numbers []int |
|||
fmt.Println("Numbers n < 6000 where: n - 1, n + 3, n + 5 are all primes:") |
|||
for n := 4; n < 6000; n += 2 { |
|||
if !c[n-1] && !c[n+3] && !c[n+5] { |
|||
numbers = append(numbers, n) |
|||
} |
|||
} |
|||
for _, n := range numbers { |
|||
fmt.Printf("%6s => ", rcu.Commatize(n)) |
|||
for _, p := range []int{n - 1, n + 3, n + 5} { |
|||
fmt.Printf("%6s ", rcu.Commatize(p)) |
|||
} |
|||
fmt.Println() |
|||
} |
|||
fmt.Printf("\n%d such numbers found.\n", len(numbers)) |
|||
}</lang> |
|||
{{out}} |
|||
<pre> |
|||
Numbers n < 6000 where: n - 1, n + 3, n + 5 are all primes: |
|||
8 => 7 11 13 |
|||
14 => 13 17 19 |
|||
38 => 37 41 43 |
|||
68 => 67 71 73 |
|||
98 => 97 101 103 |
|||
104 => 103 107 109 |
|||
194 => 193 197 199 |
|||
224 => 223 227 229 |
|||
278 => 277 281 283 |
|||
308 => 307 311 313 |
|||
458 => 457 461 463 |
|||
614 => 613 617 619 |
|||
824 => 823 827 829 |
|||
854 => 853 857 859 |
|||
878 => 877 881 883 |
|||
1,088 => 1,087 1,091 1,093 |
|||
1,298 => 1,297 1,301 1,303 |
|||
1,424 => 1,423 1,427 1,429 |
|||
1,448 => 1,447 1,451 1,453 |
|||
1,484 => 1,483 1,487 1,489 |
|||
1,664 => 1,663 1,667 1,669 |
|||
1,694 => 1,693 1,697 1,699 |
|||
1,784 => 1,783 1,787 1,789 |
|||
1,868 => 1,867 1,871 1,873 |
|||
1,874 => 1,873 1,877 1,879 |
|||
1,994 => 1,993 1,997 1,999 |
|||
2,084 => 2,083 2,087 2,089 |
|||
2,138 => 2,137 2,141 2,143 |
|||
2,378 => 2,377 2,381 2,383 |
|||
2,684 => 2,683 2,687 2,689 |
|||
2,708 => 2,707 2,711 2,713 |
|||
2,798 => 2,797 2,801 2,803 |
|||
3,164 => 3,163 3,167 3,169 |
|||
3,254 => 3,253 3,257 3,259 |
|||
3,458 => 3,457 3,461 3,463 |
|||
3,464 => 3,463 3,467 3,469 |
|||
3,848 => 3,847 3,851 3,853 |
|||
4,154 => 4,153 4,157 4,159 |
|||
4,514 => 4,513 4,517 4,519 |
|||
4,784 => 4,783 4,787 4,789 |
|||
5,228 => 5,227 5,231 5,233 |
|||
5,414 => 5,413 5,417 5,419 |
|||
5,438 => 5,437 5,441 5,443 |
|||
5,648 => 5,647 5,651 5,653 |
|||
5,654 => 5,653 5,657 5,659 |
|||
5,738 => 5,737 5,741 5,743 |
|||
46 such numbers found. |
|||
</pre> |
</pre> |
||