Munchausen numbers: Difference between revisions
Content added Content deleted
(→{{header|JavaScript}}: added zkl) |
(→{{header|Perl 6}}: Added Perl 6 solution) |
||
Line 54: | Line 54: | ||
.reduce((a, b) => a+Math.pow(parseInt(b),parseInt(b)), 0))) |
.reduce((a, b) => a+Math.pow(parseInt(b),parseInt(b)), 0))) |
||
console.log(i);</lang> |
console.log(i);</lang> |
||
{{out}} |
|||
<pre>1 |
|||
3435</pre> |
|||
=={{header|Perl 6}}== |
|||
<lang perl6>sub is_munchausen ( Int $n ) { |
|||
constant @powers = 0, |map { $_ ** $_ }, 1..9; |
|||
$n == @powers[$n.comb].sum; |
|||
} |
|||
.say if .&is_munchausen for 1..5000;</lang> |
|||
{{out}} |
{{out}} |
||
<pre>1 |
<pre>1 |