summaryrefslogtreecommitdiffstats
path: root/009.pl
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2009-05-14 20:03:00 -0500
committerJesse Luehrs <doy@tozt.net>2009-05-14 20:03:00 -0500
commit97f18c609654664782441bca016a400b7592e4c9 (patch)
treeb76c151ba24b261cd821ea29628dc23977cc10cb /009.pl
parentc3ff98ee4aa79bcaa07c8a478e96539c2a512e73 (diff)
downloadprojecteuler-97f18c609654664782441bca016a400b7592e4c9.tar.gz
projecteuler-97f18c609654664782441bca016a400b7592e4c9.zip
add solution for problem 9
Diffstat (limited to '009.pl')
-rwxr-xr-x009.pl14
1 files changed, 14 insertions, 0 deletions
diff --git a/009.pl b/009.pl
new file mode 100755
index 0000000..73cafeb
--- /dev/null
+++ b/009.pl
@@ -0,0 +1,14 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+A: for my $a (1..1000) {
+ B: for my $b (1..(1000 - $a)) {
+ my $c = 1000 - $a - $b;
+ next A if $c <= 0;
+ if ($a**2 + $b**2 == $c**2) {
+ print "$a, $b, $c: ", $a * $b * $c, "\n";
+ last A;
+ }
+ }
+}