Jump to content

Untouchable numbers: Difference between revisions

m
m (→‎{{header|C}}: Runs quicker if compiled without any optimizations (used -O3 before).)
m (→‎{{header|Wren}}: Minor tidy)
Line 1,893:
 
=={{header|Wren}}==
{{libheader|Wren-seq}}
{{libheader|Wren-math}}
{{libheader|Wren-fmt}}
Line 1,899 ⟶ 1,898:
===Version 1===
Run time about 70 seconds on my Core i7 machine.
<syntaxhighlight lang="ecmascriptwren">import "./math" for Int, Nums
import "./seqfmt" for LstFmt
import "/fmt" for Fmt
 
var sieve = Fn.new { |n|
Line 1,924 ⟶ 1,922:
 
System.print("List of untouchable numbers <= 2,000:")
for Fmt.tprint(chunk"$,6d", in Lst.chunks(untouchable.where { |n| n <= 2000 }.toList, 10)) {
Fmt.print("$,6d", chunk)
}
System.print()
Fmt.print("$,6d untouchable numbers were found <= 2,000", untouchable.count { |n| n <= 2000 })
Line 1,978 ⟶ 1,974:
 
Run time for untouchable numbers up to 100,000 (m = 14) is now only 1.4 seconds and 1,000,000 (m = 63) is reached in 132 seconds.
<syntaxhighlight lang="ecmascriptwren">import "./math" for Int, Nums
import "./seqfmt" for LstFmt
import "/fmt" for Fmt
 
var limit = 1e6
Line 2,006 ⟶ 2,001:
}
System.print("List of untouchable numbers <= 2,000:")
for Fmt.tprint(chunk"$,6d", in Lst.chunks(untouchable.where { |n| n <= 2000 }.toList, 10)) {
Fmt.print("$,6d", chunk)
}
System.print()
Fmt.print("$,7d untouchable numbers were found <= 2,000", untouchable.count { |n| n <= 2000 })
9,485

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.