Narcissistic decimal number: Difference between revisions

Perl 6 entry
(New draft task and Python solution.)
 
(Perl 6 entry)
Line 1:
{{draft task}}
A [http://mathworld.wolfram.com/NarcissisticNumber.html Narcissistic decimal number] is a positice decimal number, <math>n</math> in which if there are <math>m</math> digits in the sumbernumber then the sum of all the individual digits of the number raised to the power <math>m</math> is equal to <math>n</math>.
 
For example, if <math>n</math> is 153 then <math>m</math>, the number of digits is 3 and we have <math>1^3+5^3+3^3 = 1+125+27 = 153</math> and so 153 is a narcissistic decimal number.
 
The task is to generate and show here, the first 25 narcissistic numbers.
 
=={{header|Perl6}}==
Here is a straightforward, naive implementation. Should work but takes ages.
<lang perl6>sub is-narcissic(Int $n) { $n == ([+] $n.comb)**$n.chars }
 
say (grep &is-narcissic, 0 .. *)[^15];</lang>
 
=={{header|Python}}==
1,934

edits