Narcissistic decimal number: Difference between revisions
m
→{{header|Raku}}: split versions apart, add concurrency to 1st
SqrtNegInf (talk | contribs) m (→{{header|Perl}}: now with v5.36, add output) |
SqrtNegInf (talk | contribs) m (→{{header|Raku}}: split versions apart, add concurrency to 1st) |
||
Line 4,329:
=={{header|Raku}}==
(formerly Perl 6)
===Simple, with concurrency===
Simple implementation is not exactly speedy, but concurrency helps move things along.
<lang perl6>sub is-narcissistic(Int $n) { $n == [+] $n.comb »**» $n.chars }
@N[^25].join(' ').say;</lang>
▲ if .&is-narcissistic {
{{out}}
<pre>0 1 2 3 4 5 6 7 8 9 153 370 371 407 1634 8208 9474 54748 92727 93084 548834 1741725 4210818 9800817 9926315</pre>
===Single-threaded, with precalculations===
This version that precalculates the values for base 1000 digits, but despite the extra work ends up taking more wall-clock time than the simpler version.
<lang perl6>sub kigits($n) {
my int $i = $n;
|