Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
18
Task/Summarize-primes/Wren/summarize-primes.wren
Normal file
18
Task/Summarize-primes/Wren/summarize-primes.wren
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import "/math" for Int
|
||||
import "/fmt" for Fmt
|
||||
|
||||
var primes = Int.primeSieve(999)
|
||||
var sum = 0
|
||||
var n = 0
|
||||
var c = 0
|
||||
System.print("Summing the first n primes (<1,000) where the sum is itself prime:")
|
||||
System.print(" n cumulative sum")
|
||||
for (p in primes) {
|
||||
n = n + 1
|
||||
sum = sum + p
|
||||
if (Int.isPrime(sum)) {
|
||||
c = c + 1
|
||||
Fmt.print("$3d $,6d", n, sum)
|
||||
}
|
||||
}
|
||||
System.print("\n%(c) such prime sums found")
|
||||
Loading…
Add table
Add a link
Reference in a new issue