C
ccc31807
Pythagorian triples are integers that form the sides of a right
triangle, e.g., 3, 4, 5. I've posted an iterative version below for
all triples less than 100. I'm having trouble coming up with a
recursive version. Any ideas?
CC
#! perl
use strict;
use warnings;
print "Pythagorian triples\n\n";
for(my $i = 1; $i < 101; $i++)
{
for(my $j = 1; $j < 101; $j++)
{
for(my $k = 1; $k < 101; $k++)
{
print "$i - $j - $k\n" if ($i * $i + $j * $j) == ($k * $k);
}
}
}
exit(0);
triangle, e.g., 3, 4, 5. I've posted an iterative version below for
all triples less than 100. I'm having trouble coming up with a
recursive version. Any ideas?
CC
#! perl
use strict;
use warnings;
print "Pythagorian triples\n\n";
for(my $i = 1; $i < 101; $i++)
{
for(my $j = 1; $j < 101; $j++)
{
for(my $k = 1; $k < 101; $k++)
{
print "$i - $j - $k\n" if ($i * $i + $j * $j) == ($k * $k);
}
}
}
exit(0);