Primes whose sum of digits is 25: Difference between revisions

m
(→‎J: add)
m (→‎{{header|Wren}}: Minor tidy)
 
(One intermediate revision by one other user not shown)
Line 1,109:
 
=={{header|J}}==
<syntaxhighlight lang="j"> (#~ (25 = [: +/ @("."0@":)"0) p: i. _1 p: 5000
997 1699 1789 1879 1987 2689 2797 2887 3499 3697 3769 3877 3967 4597 4759 4957 4993</syntaxhighlight>
 
Line 2,217:
{{libheader|Wren-math}}
{{libheader|Wren-fmt}}
<syntaxhighlight lang="wren">import "./math" for Int
{{libheader|Wren-seq}}
<syntaxhighlight lang="ecmascript">import "./mathfmt" for IntFmt
import "/fmt" for Fmt
import "/seq" for Lst
 
var sumDigits = Fn.new { |n|
Line 2,237 ⟶ 2,235:
}
System.print("The %(primes25.count) primes under 5,000 whose digits sum to 25 are:")
for (chunk in Lst.chunks(primes25, 6)) Fmt.printtprint("$,6d", chunkprimes25, 6)</syntaxhighlight>
 
{{out}}
Line 2,250 ⟶ 2,248:
{{libheader|Wren-gmp}}
Run time is about 25.5 seconds.
<syntaxhighlight lang="ecmascriptwren">import "./gmp" for Mpz
import "./fmt" for Fmt
 
9,476

edits