Narcissistic decimal number: Difference between revisions

m
→‎{{header|Perl}}: now with v5.36, add output
m (→‎{{header|Perl}}: now with v5.36, add output)
Line 3,463:
 
=={{header|Perl}}==
Simple version using a naive predicate. About 15 seconds.
<lang perl>subuse is_narcissistic {v5.36;
 
my $n = shift;
sub is_narcissistic ($n) {
my($k,$sum) = (length($n),0);
$sum += $_**my($k, for$sum) = split(//,length $n, 0);
$nsum =+= $sum_**$k for split '', $n;
my $n == shift;$sum
}
 
my $i = 0;
formy (1..25$i,@N) {= 0;
while (@N < 25) {
$i++ while !not is_narcissistic( $i);
say $i++;
push @N, $i++
}</lang>
}
 
say join ' ', @N;</lang>
{{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>
 
=={{header|Phix}}==
2,392

edits