Digit fifth powers: Difference between revisions
Content added Content deleted
(Ada version) |
SqrtNegInf (talk | contribs) (Added Perl) |
||
Line 296: | Line 296: | ||
194979 |
194979 |
||
Total: 443839</pre> |
Total: 443839</pre> |
||
=={{header|Perl}}== |
|||
<lang perl>use strict; |
|||
use warnings; |
|||
use feature 'say'; |
|||
use List::Util 'sum'; |
|||
for my $power (3..6) { |
|||
my @matches; |
|||
for my $n (2 .. 9**$power * $power) { |
|||
push @matches, $n if $n == sum map { $_**$power } split '', $n; |
|||
} |
|||
say "\nSum of powers of n**$power: " . join(' + ', @matches) . ' = ' . sum @matches; |
|||
}</lang> |
|||
{{out}} |
|||
<pre>Sum of powers of n**3: 153 + 370 + 371 + 407 = 1301 |
|||
Sum of powers of n**4: 1634 + 8208 + 9474 = 19316 |
|||
Sum of powers of n**5: 4150 + 4151 + 54748 + 92727 + 93084 + 194979 = 443839 |
|||
Sum of powers of n**6: 548834 = 548834</pre> |
|||
=={{header|Python}}== |
=={{header|Python}}== |