pythagorean triples exercise

Terry Reedy tjreedy at udel.edu
Thu Oct 21 17:18:00 EDT 2010


On 10/21/2010 6:55 AM, Baba wrote:
> Hi everyone
>
> i need a hint regarding the following exercise question:
>
> "Write a program that generates all Pythagorean triples whose small
> sides are no larger than n.

This is not well worded. I take 'small sides' (plural) to mean the two 
smaller, non-hypotenuse sides (which are necessarily shorter than the 
hypotenuse). So the possible pairs of values i,j, where i is the shorter 
of the two, have

> Try it with n<= 200."

Again, not well worded; I believe this is meant to be n==200, except 
that the program should take n as a parameter and then give it value 
200, so that the could work if n were given some other value.

So the possible pairs of values i,j, where i is the shorter of the two, 
have j <= n (==200) and i <= j.

-- 
Terry Jan Reedy




More information about the Python-list mailing list