Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
23
Task/Summarize-primes/Go/summarize-primes.go
Normal file
23
Task/Summarize-primes/Go/summarize-primes.go
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"rcu"
|
||||
)
|
||||
|
||||
func main() {
|
||||
primes := rcu.Primes(999)
|
||||
sum, n, c := 0, 0, 0
|
||||
fmt.Println("Summing the first n primes (<1,000) where the sum is itself prime:")
|
||||
fmt.Println(" n cumulative sum")
|
||||
for _, p := range primes {
|
||||
n++
|
||||
sum += p
|
||||
if rcu.IsPrime(sum) {
|
||||
c++
|
||||
fmt.Printf("%3d %6s\n", n, rcu.Commatize(sum))
|
||||
}
|
||||
}
|
||||
fmt.Println()
|
||||
fmt.Println(c, "such prime sums found")
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue