Erdős-Nicolas numbers: Difference between revisions

Added Easylang
(Added Go)
(Added Easylang)
 
(21 intermediate revisions by 10 users not shown)
Line 272:
{{out}}
<pre>Same as FreeBASIC entry.</pre>
 
=={{header|C}}==
{{trans|C++}}
Run time about 46 seconds.
<syntaxhighlight lang="c">#include <stdio.h>
#include <stdlib.h>
 
int main() {
const int maxNumber = 100000000;
int *dsum = (int *)malloc((maxNumber + 1) * sizeof(int));
int *dcount = (int *)malloc((maxNumber + 1) * sizeof(int));
int i, j;
for (i = 0; i <= maxNumber; ++i) {
dsum[i] = 1;
dcount[i] = 1;
}
for (i = 2; i <= maxNumber; ++i) {
for (j = i + i; j <= maxNumber; j += i) {
if (dsum[j] == j) {
printf("%8d equals the sum of its first %d divisors\n", j, dcount[j]);
}
dsum[j] += i;
++dcount[j];
}
}
free(dsum);
free(dcount);
return 0;
}</syntaxhighlight>
 
{{out}}
<pre>
24 equals the sum of its first 6 divisors
2016 equals the sum of its first 31 divisors
8190 equals the sum of its first 43 divisors
42336 equals the sum of its first 66 divisors
45864 equals the sum of its first 66 divisors
714240 equals the sum of its first 113 divisors
392448 equals the sum of its first 68 divisors
1571328 equals the sum of its first 115 divisors
61900800 equals the sum of its first 280 divisors
91963648 equals the sum of its first 142 divisors
</pre>
===slight improvement===
dsum and dcount are in "far" distance -> cache miss. Using an struct "typedef struct { int divsum, divcnt;} divs;" improves runtime to 32 s.
Calculating the count of divisors only at output saves 50% space and runtime too.
<syntaxhighlight lang=c>#include <stdio.h>
#include <stdlib.h>
 
void get_div_cnt(int n){
int lmt,f,divcnt,divsum;
divsum = 1;
divcnt = 1;
lmt = n/2;
f = 2;
for (;;) {
if (f > lmt ) break;
if (!(n % f)){
divsum +=f;
divcnt++;
}
if (divsum == n) break;
f++;
}
printf("%8d equals the sum of its first %d divisors\n", n, divcnt);
}
 
int main() {
const int maxNumber = 100*1000*1000;
int *dsum = (int *)malloc((maxNumber + 1) * sizeof(int));
int i, j;
for (i = 0; i <= maxNumber; ++i) {
dsum[i] = 1;
}
for (i = 2; i <= maxNumber; ++i) {
for (j = i + i; j <= maxNumber; j += i) {
if (dsum[j] == j) get_div_cnt(j);
dsum[j] += i;
}
}
free(dsum);
return 0;
}</syntaxhighlight>
{{out|TIO.RUN}}
<pre> the same.
compiler flags -march=native -O2
Real time: 23.893 s User time: 23.475 s Sys. time: 0.203 s CPU share: 99.10 %
//Sys. time: up to 8s for version before???
//with lmt 2,000,000 the results on TIO.RUN are more stable.
version before
User time: 0.304 s CPU share: 98.93 %
slight improvement version
User time: 0.139 s CPU share: 98.80 %
</pre>
 
=={{header|C#}}==
{{trans|Java}}
<syntaxhighlight lang="C#">
using System;
 
class ErdosNicolasNumbers
{
static void Main(string[] args)
{
const int limit = 100_000_000;
int[] divisorSum = new int[limit + 1];
int[] divisorCount = new int[limit + 1];
for (int i = 0; i <= limit; i++)
{
divisorSum[i] = 1;
divisorCount[i] = 1;
}
for (int index = 2; index <= limit / 2; index++)
{
for (int number = 2 * index; number <= limit; number += index)
{
if (divisorSum[number] == number)
{
Console.WriteLine($"{number,8} equals the sum of its first {divisorCount[number],3} divisors");
}
divisorSum[number] += index;
divisorCount[number]++;
}
}
}
}
</syntaxhighlight>
{{out}}
<pre>
24 equals the sum of its first 6 divisors
2016 equals the sum of its first 31 divisors
8190 equals the sum of its first 43 divisors
42336 equals the sum of its first 66 divisors
45864 equals the sum of its first 66 divisors
714240 equals the sum of its first 113 divisors
392448 equals the sum of its first 68 divisors
1571328 equals the sum of its first 115 divisors
61900800 equals the sum of its first 280 divisors
91963648 equals the sum of its first 142 divisors
</pre>
 
=={{header|C++}}==
Line 309 ⟶ 452:
91963648 equals the sum of its first 142 divisors
</pre>
 
=={{header|Delphi}}==
{{works with|Delphi|6.0}}
{{libheader|SysUtils,StdCtrls}}
Translation from the C version. Runs in 38 seconds
 
<syntaxhighlight lang="Delphi">
 
const MaxNumber = 100000000;
var DSum: array [0..MaxNumber-1] of integer;
var DCount: array [0..MaxNumber-1] of integer;
 
procedure ShowErdosNicolasNumbers(Memo: TMemo);
var I,J: integer;
begin
for I:=0 to MaxNumber-1 do
begin
DSum[I]:=1;
DCount[I]:=1;
end;
for I:=2 to MaxNumber-1 do
begin
J:=I*2;
while J<MaxNumber do
begin
if dsum[J] = j then
begin
Memo.Lines.Add(Format('%8d equals the sum of its first %d divisors', [j, dcount[j]]));
end;
Inc(dsum[J],I);
Inc(DCount[J]);
Inc(J,I);
end;
end;
end;
 
 
</syntaxhighlight>
{{out}}
<pre>
24 equals the sum of its first 6 divisors
2016 equals the sum of its first 31 divisors
8190 equals the sum of its first 43 divisors
42336 equals the sum of its first 66 divisors
45864 equals the sum of its first 66 divisors
714240 equals the sum of its first 113 divisors
392448 equals the sum of its first 68 divisors
1571328 equals the sum of its first 115 divisors
61900800 equals the sum of its first 280 divisors
91963648 equals the sum of its first 142 divisors
</pre>
 
=={{header|EasyLang}}==
{{trans|FreeBASIC}}
<syntaxhighlight>
limit = 2000000
for i to limit
dsum[] &= 1
dcnt[] &= 1
.
for i = 2 to limit
j = i + i
while j <= limit
if dsum[j] = j
print j & " equals the sum of its first " & dcnt[j] & " divisors"
.
dsum[j] += i
dcnt[j] += 1
j += i
.
.
</syntaxhighlight>
 
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">
_limit = 500000
 
void local fn ErdosNicolasNumbers
long i, j, sum( _limit ), count( _limit )
for i = 0 to _limit
sum(i) = 1
count(i) = 1
next
for i = 2 to _limit
j = i + i
while ( j <= _limit )
if sum(j) == j then printf @"%8ld == sum of its first %3ld divisors", j, count(j)
sum(j) = sum(j) + i
count(j) = count(j) + 1
j = j + i
wend
next
end fn
 
fn ErdosNicolasNumbers
 
HandleEvents
</syntaxhighlight>
{{output}}
<pre>
24 == sum of its first 6 divisors
2016 == sum of its first 31 divisors
8190 == sum of its first 43 divisors
42336 == sum of its first 66 divisors
45864 == sum of its first 66 divisors
392448 == sum of its first 68 divisors
</pre>
 
=={{header|Go}}==
Line 363 ⟶ 615:
714240 113
1571328 115</syntaxhighlight>
 
=={{header|Java}}==
<syntaxhighlight lang="java">
import java.util.Arrays;
 
public final class ErdosNicolasNumbers {
 
public static void main(String[] aArgs) {
final int limit = 100_000_000;
int[] divisorSum = new int[limit + 1];
int[] divisorCount = new int[limit + 1];
Arrays.fill(divisorSum, 1);
Arrays.fill(divisorCount, 1);
for ( int index = 2; index <= limit / 2; index++ ) {
for ( int number = 2 * index; number <= limit; number += index ) {
if ( divisorSum[number] == number ) {
System.out.println(String.format("%8d", number) + " equals the sum of its first "
+ String.format("%3d", divisorCount[number]) + " divisors");
}
divisorSum[number] += index;
divisorCount[number]++;
}
}
}
 
}
</syntaxhighlight>
{{ out }}
<pre>
24 equals the sum of its first 6 divisors
2016 equals the sum of its first 31 divisors
8190 equals the sum of its first 43 divisors
42336 equals the sum of its first 66 divisors
45864 equals the sum of its first 66 divisors
714240 equals the sum of its first 113 divisors
392448 equals the sum of its first 68 divisors
1571328 equals the sum of its first 115 divisors
61900800 equals the sum of its first 280 divisors
91963648 equals the sum of its first 142 divisors
</pre>
 
=={{header|jq}}==
'''Adapted from [[#Wren]]'''
 
'''Works with jq and gojq, the C and Go implementations of jq'''
 
The following program will also work using jaq provided `sqrt` is defined appropriately
and other minor adjustments are made.
<syntaxhighlight lang=jq>
# Output a stream of the (unsorted) proper divisors of . including 1
def proper_divisors:
. as $n
| if $n > 1 then 1,
( range(2; 1 + sqrt) as $i
| if ($n % $i) == 0 then $i,
(($n / $i) | if . == $i then empty else . end)
else empty
end)
else empty
end;
 
# Emit k if . is an Erdos-Nicolas number, otherwise emit 0
def erdosNicolas:
. as $n
| ([proper_divisors] | sort) as $divisors
| ($divisors|length) as $dc
| if $dc < 3 then 0
else {sum: ($divisors[0] + $divisors[1])}
# An Erdos-Nicolas is not perfect, and hence $dc-1 in the following line:
| first(
foreach range(2; $dc-1) as $i (.;
.sum += $divisors[$i]
| if .sum == $n then .emit = $i + 1
elif .sum > $n then .emit = 0
else .
end )
| select(.emit).emit ) // 0
end ;
 
limit(8;
range(2; infinite)
| . as $n
| erdosNicolas as $k
| select($k > 0)
| "\($n) from \($k)" )
</syntaxhighlight>
{{output}}
<pre>
24 from 6
2016 from 31
8190 from 43
42336 from 66
45864 from 66
392448 from 68
714240 from 113
1571328 from 115
</pre>
 
=={{header|Julia}}==
Line 397 ⟶ 749:
714240 equals the sum of its first 113 divisors.
1571328 equals the sum of its first 115 divisors.
</pre>
 
=={{header|Nim}}==
{{trans|Go}}
To get better performances, we use 32 bits integers rather than 64 bits integers. We got the best (and excellent) execution time with compilation command: <code>nim c -d:release -d:lto --gc:boehm erdos_nicolas_numbers.nim</code>
<syntaxhighlight lang="Nim">import std/[sequtils, strformat]
 
proc main() =
const MaxNumber = 100_000_000i32
var dsum, dcount = repeat(1'i32, MaxNumber + 1)
for i in 2i32..MaxNumber:
for j in countup(i + i, MaxNumber, i):
if dsum[j] == j:
echo &"{j:>8} equals the sum of its first {dcount[j]} divisors"
inc dsum[j], i
inc dcount[j]
main()
</syntaxhighlight>
{{out}}
<pre> 24 equals the sum of its first 6 divisors
2016 equals the sum of its first 31 divisors
8190 equals the sum of its first 43 divisors
42336 equals the sum of its first 66 divisors
45864 equals the sum of its first 66 divisors
714240 equals the sum of its first 113 divisors
392448 equals the sum of its first 68 divisors
1571328 equals the sum of its first 115 divisors
61900800 equals the sum of its first 280 divisors
91963648 equals the sum of its first 142 divisors
</pre>
 
=={{header|Pascal}}==
==={{header|Free Pascal}}===
using [[Factors_of_an_integer#using_Prime_decomposition]] , using a sort of sieve.
<syntaxhighlight lang="pascal">
program ErdoesNumb;
 
//formerly program FacOfInt;
// gets factors of consecutive integers fast
// limited to 1.2e11
{$IFDEF FPC}
{$MODE DELPHI} {$OPTIMIZATION ON,ALL} {$COPERATORS ON}
{$ENDIFELSE}
{$IFDEF WINDOWS}
{$APPTYPE CONSOLE}
{$ENDIF}
Line 422 ⟶ 803:
HCN_DivCnt = 4096;
type
tItem = Uint64;
tDivisors = array [0..HCN_DivCnt] of tItem;
tpDivisor = pUint64;
const
 
SizePrDeFe = 32768;//*56 <= 64kb level I or 2 Mb ~ level 2 cache or more
type
tdigits = array [0..31] of Uint32;
//the first number with 11 different prime factors =
//2*3*5*7*11*13*17*19*23*29*31 = 2E11
Line 435 ⟶ 818:
pfDivCnt : Uint32;
pfMaxIdx : Uint32;
pfpotPrimIdx : array[0..9] of word;
pfpotMax : array[0..11] of byte;
pfpotPrimIdx : array[0..9] of word;
end;
tpPrimeFac = ^tprimeFac;
 
tPrimeDecompField = array[0..SizePrDeFe-1] of tprimeFac;
tPrimes = array[0..65535] of Uint32;
 
var
{$ALIGN 8}
SmallPrimes: tPrimes;
{$ALIGN 32}
PrimeDecompField :tPrimeDecompField;
pdfIDX,pdfOfs: NativeInt;
 
procedure InitSmallPrimes;
Line 487 ⟶ 876:
end;
 
function smplPrimeDecompCnvtoBASE(var dgt:tDigits;n:Uint64;base:NativeUint):tprimeFacNativeInt;
//n must be multiple of base aka n mod base must be 0
var
q,r: Uint64;
pr,i,pot,fac,q :NativeUInt;
i : NativeInt;
Begin
fillchar(dgt,SizeOf(dgt),#0);
with result do
Begini := 0;
pfDivCntn := 1n div base;
pfSumOfDivsresult := 10;
repeat
pfRemain := n;
pfMaxIdxr := 0n;
pfpotPrimIdx[0]q := 1n div base;
pfpotMax[0]r : -= 0q*base;
n := q;
dgt[i] := r;
inc(i);
until (q = 0);
//searching lowest pot in base
result := 0;
while (result<i) AND (dgt[result] = 0) do
inc(result);
inc(result);
end;
 
function IncByBaseInBase(var dgt:tDigits;base:NativeInt):NativeInt;
i := 0;
var
while i < High(SmallPrimes) do
q :NativeInt;
Begin
result := 0;
q := dgt[result]+1;
if q = base then
repeat
dgt[result] := 0;
inc(result);
q := dgt[result]+1;
until q <> base;
dgt[result] := q;
result +=1;
end;
 
function SieveOneSieve(var pdf:tPrimeDecompField):boolean;
var
dgt:tDigits;
i,j,k,pr,fac,n,MaxP : Uint64;
begin
n := pdfOfs;
if n+SizePrDeFe >= sqr(SmallPrimes[High(SmallPrimes)]) then
EXIT(FALSE);
//init
for i := 0 to SizePrDeFe-1 do
begin
with pdf[i] do
Begin
pfDivCnt := 1;
pfSumOfDivs := 1;
pfRemain := n+i;
pfMaxIdx := 0;
pfpotPrimIdx[0] := 0;
pfpotMax[0] := 0;
end;
end;
//first factor 2. Make n+i even
i := (pdfIdx+n) AND 1;
IF (n = 0) AND (pdfIdx<2) then
i := 2;
 
repeat
with pdf[i] do
begin
prj := SmallPrimes[BsfQWord(n+i]);
qpfMaxIdx := n DIV pr1;
//ifpfpotPrimIdx[0] n:= < pr*pr0;
ifpfpotMax[0] pr:= > q thenj;
pfRemain := (n+i) BREAKshr j;
if npfSumOfDivs := pr*q(Uint64(1) shl then(j+1))-1;
pfDivCnt := j+1;
end;
i += 2;
until i >=SizePrDeFe;
//i now index in SmallPrimes
i := 0;
maxP := trunc(sqrt(n+SizePrDeFe))+1;
repeat
//search next prime that is in bounds of sieve
if n = 0 then
begin
repeat
inc(i);
pr := SmallPrimes[i];
k := pr-n MOD pr;
if k < SizePrDeFe then
break;
until pr > MaxP;
end
else
begin
repeat
inc(i);
pr := SmallPrimes[i];
k := pr-n MOD pr;
if (k = pr) AND (n>0) then
k:= 0;
if k < SizePrDeFe then
break;
until pr > MaxP;
end;
 
//no need to use higher primes
if pr*pr > n+SizePrDeFe then
BREAK;
 
//j is power of prime
j := CnvtoBASE(dgt,n+k,pr);
repeat
with pdf[k] do
Begin
pfpotPrimIdx[pfMaxIdx] := i;
potpfpotMax[pfMaxIdx] := 0j;
pfDivCnt *= j+1;
fac := pr;
repeat
npfRemain := qpfRemain DIV pr;
q := n div prdec(j);
pot+=1;
fac *= pr;
until n j<>= pr*q0;
pfpotMax[pfMaxIdx] := pot;
pfDivCnt *= pot+1;
pfSumOfDivs *= (fac-1)DIV(pr-1);
inc(pfMaxIdx);
k += pr;
j := IncByBaseInBase(dgt,pr);
end;
until k >= SizePrDeFe;
until false;
 
//correct sum of & count of divisors
for i := 0 to High(pdf) do
Begin
with pdf[i] do
begin
j := pfRemain;
if j <> 1 then
begin
pfSumOFDivs *= (j+1);
pfDivCnt *=2;
end;
inc(i);
end;
pfRemain := n;
if n > 1 then
Begin
pfDivCnt *= 2;
pfSumOfDivs *= n+1
end;
end;
result := true;
end;
 
function NextSieve:boolean;
begin
dec(pdfIDX,SizePrDeFe);
inc(pdfOfs,SizePrDeFe);
result := SieveOneSieve(PrimeDecompField);
end;
 
function GetNextPrimeDecomp:tpPrimeFac;
begin
if pdfIDX >= SizePrDeFe then
if Not(NextSieve) then
EXIT(NIL);
result := @PrimeDecompField[pdfIDX];
inc(pdfIDX);
end;
 
function Init_Sieve(n:NativeUint):boolean;
//Init Sieve pdfIdx,pdfOfs are Global
begin
pdfIdx := n MOD SizePrDeFe;
pdfOfs := n-pdfIdx;
result := SieveOneSieve(PrimeDecompField);
end;
 
Line 601 ⟶ 1,116:
 
var
pPrimeDecomp :tpPrimeFac;
Mypd : tPrimeFac;
Divs:tDivisors;
pDivs : tpDivisor;
T0:Int64;
i: NativeInt;
n,s : NativeUInt;
i : Int32;
Begin
InitSmallPrimes;
T0 := GetTickCount64;
InitSmallPrimes;
Init_Sieve(0);
//jump over 0
pPrimeDecomp:= GetNextPrimeDecomp;
n := 1;
pDivs := @Divs[0];
repeat
MypdpPrimeDecomp:= smplPrimeDecomp(n)GetNextPrimeDecomp;
ifs Mypd:= pPrimeDecomp^.pfSumOfDivs>2*n then;
if (s > 2*n) then
begin
GetDivisors(@Mypd,Divs)s -= n;
s// :=75% 1;of runtime
GetDivisors(pPrimeDecomp,Divs);
For i := 1 to Mypd.pfDivCnt-3 do
//calculate downwards. Not really an impact
For i := pPrimeDecomp^.pfDivCnt-2 downto 0 do
Begin
inc(s,pDivs -= Divs[i]);
if s<n then
break;
if s = n then
writeln(Format('%8d equals the sum of its first %4d divisors',
[n,i+1]));
if s>n then
break;
end;
end;
n += 1;
until n > 2100*1000*1000+1;
T0 := GetTickCount64-T0;
writeln('runtime ',T0/1000:0:3,' s');
end.
end.</syntaxhighlight>
</syntaxhighlight>
{{out|@TIO.RUN}}
<pre>
TIO.RUN
24 equals the sum of its first 6 divisors
2016 equals the sum of its first 31 divisors
Line 643 ⟶ 1,162:
392448 equals the sum of its first 68 divisors
714240 equals the sum of its first 113 divisors
1571328 equals the sum of its first 115 divisors
runtime 1.219 s
@home
...
1571328 equals the sum of its first 115 divisors
61900800 equals the sum of its first 280 divisors
91963648 equals the sum of its first 142 divisors
runtime 4015.504760 s</pre>
 
Real time: 15.909 s User time: 15.721 s CPU share: 99.09 %
</pre>
 
=={{header|Perl}}==
{{libheader|ntheory}}
<syntaxhighlight lang="perl" line>use v5.36;
use enum qw(False True);
use ntheory 'divisors';
use enumntheory qw(Falsedivisors Truedivisor_sum);
use List::AllUtils <firstidx sum>;
 
sub proper_divisors ($n) {
return 1 if $n == 0;
my @d = divisors($n);
pop @d;
@d;
}
 
sub is_Erdos_Nicolas ($n) {
 
my @divisors = proper_divisors($n);
divisor_sum($n) > 2*$n or return False;
return False unless sum(@divisors) > $n;
 
my $sum;
my $keysum = firstidx { $_ == $n } map { $sum += $_ } @divisors0;
$key ? 1 +my $keycount := False0;
 
foreach my $d (divisors($n)) {
++$count; $sum += $d;
return $count if ($sum == $n);
return False if ($sum > $n);
}
}
 
my ($n, $count) = (2, 0);
until ($count == 8) {
next unless 0 == ++$n % 2;
if (my $key = is_Erdos_Nicolas $n) {
printf "%8d == sum of its first %3d divisors\n", $n, $key;
$count++;
}
}</syntaxhighlight>
Line 720 ⟶ 1,237:
Output same as Julia
 
=={{header|Python}}==
{{trans|C}}
This is a translation of the "slight improvement" C code. I ran this script using PyPy7.3.13 (Python3.10.13) and it completes in ~10.5s on a AMD Ryzen 7 7800X3D.
<syntaxhighlight lang="python">
# erdos-nicolas.py by Xing216
from time import perf_counter
start = perf_counter()
def get_div_cnt(n: int) -> None:
divcnt,divsum = 1,1
lmt = n/2
f = 2
while True:
if f > lmt: break
if not (n % f):
divsum += f
divcnt += 1
if divsum == n: break
f+=1
print(f"{n:>8} equals the sum of its first {divcnt} divisors")
max_number = 91963649
dsum = [1 for _ in range(max_number+1)]
for i in range(2, max_number + 1):
for j in range(i + i, max_number + 1, i):
if (dsum[j] == j): get_div_cnt(j)
dsum[j] += i
done = perf_counter() - start
print(f"Done in: {done:.3f}s")
</syntaxhighlight>
{{out}}
<pre>
24 equals the sum of its first 6 divisors
2016 equals the sum of its first 31 divisors
8190 equals the sum of its first 43 divisors
42336 equals the sum of its first 66 divisors
45864 equals the sum of its first 66 divisors
714240 equals the sum of its first 113 divisors
392448 equals the sum of its first 68 divisors
1571328 equals the sum of its first 115 divisors
61900800 equals the sum of its first 280 divisors
91963648 equals the sum of its first 142 divisors
Done in: 10.478s
</pre>
=={{header|Raku}}==
<syntaxhighlight lang="raku" line>use Prime::Factor;
Line 786 ⟶ 1,345:
392448 equals the sum of its first 68 divisors
1571328 equals the sum of its first 115 divisors
</pre>
 
=={{header|Sidef}}==
<syntaxhighlight lang="ruby">func is_Erdős_Nicolas(n) {
 
n.is_abundant || return false
 
var sum = 0
var count = 0
 
n.divisors.each {|d|
++count; sum += d
return count if (sum == n)
return false if (sum > n)
}
}
 
var count = 8 # how many terms to compute
 
^Inf -> by(2).each {|n|
if (is_Erdős_Nicolas(n)) { |v|
say "#{'%8s'%n} is the sum of its first #{'%3s'%v} divisors"
--count || break
}
}</syntaxhighlight>
{{out}}
<pre>
24 is the sum of its first 6 divisors
2016 is the sum of its first 31 divisors
8190 is the sum of its first 43 divisors
42336 is the sum of its first 66 divisors
45864 is the sum of its first 66 divisors
392448 is the sum of its first 68 divisors
714240 is the sum of its first 113 divisors
1571328 is the sum of its first 115 divisors
</pre>
 
Line 791 ⟶ 1,385:
===Version 1===
{{libheader|Wren-math}}
<syntaxhighlight lang="ecmascriptwren">import "./math" for Int
 
var erdosNicolas = Fn.new { |n|
Line 837 ⟶ 1,431:
 
If `maxNum` is set to 2 million, then it finds the first 8 in about 5.2 seconds which is more than 10 times faster than Version 1's 58 seconds.
<syntaxhighlight lang="ecmascriptwren">import "./fmt" for Fmt
 
var maxNum = 1e8
1,983

edits