summaryrefslogtreecommitdiffstats
path: root/034.pl
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2009-05-15 18:09:58 -0500
committerJesse Luehrs <doy@tozt.net>2009-05-15 18:09:58 -0500
commit49260ea122d3e6c5e1aab89e65b8cb8cdb10df48 (patch)
tree07817bd2d079b05dc587cf93f1cf8b33b4692d58 /034.pl
parentf2d2341ab1e322fb986a9a6ef4681234d28eabe0 (diff)
downloadprojecteuler-49260ea122d3e6c5e1aab89e65b8cb8cdb10df48.tar.gz
projecteuler-49260ea122d3e6c5e1aab89e65b8cb8cdb10df48.zip
problem 34 solution
Diffstat (limited to '034.pl')
-rwxr-xr-x034.pl13
1 files changed, 13 insertions, 0 deletions
diff --git a/034.pl b/034.pl
new file mode 100755
index 0000000..4a44609
--- /dev/null
+++ b/034.pl
@@ -0,0 +1,13 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use List::Util qw/sum/;
+use Math::Combinatorics qw/factorial/;
+
+my @numbers;
+for my $i (10..500000) {
+ my @digits = split //, $i;
+ my $sum = sum map { factorial($_) } @digits;
+ push @numbers, $i if $i == $sum;
+}
+print join('+', @numbers), ' = ', sum(@numbers), "\n";