in reply to Re: Pythagorean theorem
in thread Pythagorean's theorem

Definitely something amiss here. It doesn't limit the arg like it should. For example, where $max=10, it pushes side "b" as high as 180.

-fuzzyping

Replies are listed 'Best First'.
Re: Re: Re: Pythagorean theorem
by I0 (Priest) on Feb 27, 2002 at 23:53 UTC
    #!/usr/bin/perl use strict; my $max = shift or die "Usage: $0 <max len>\n"; for my $t ( 2..sqrt$max ){ for my $s ( 1..$t-1 ){ my $c=$t*$t+$s*$s; next unless $c <= $max; my $a = $t*$t-$s*$s; my $b = 2*$s*$t; print "$a $b $c is a winner\n"; } }