home *** CD-ROM | disk | FTP | other *** search
-
- "!
- ODD.MSE, 7/24/86, Lee R. Bradley
- !"
-
- "!Want some background? " ?' r:
- r. 'y = r. 'Y = +
- [
- "!
- A man lives on a long street in Hartford. The house numbers
- are odd on his side. If the sum of the house numbers on one
- side of his house equals the sum of the numbers on the other
- side of his house, how many houses are there and what is his
- house number ? Here's a picture. x represents the position
- of the man's house. His house number would be 2*x -1. y
- represents the position of the last house on the street.
- "
- ]
- "!
- 1 ..... x-1 x x+1 ..... y
-
- "
-
- ~ It can be shown that (x-1)*(x-1) + x*x = y*y .
- ~ As they say, the proof is left as an exercise
- ~ for the reader.
-
- 1 s :
-
- (
- s. ^
- "
- Enter a value greater than 50 and less than 500. This will
- be used as the first value of x, which represents the position
- of the man's house. The program will try it and continue to
- increment it until a solution is found.
- Your number please. "
- ? x :
- x. 50 > x. 501 < * [0 s :]
- s. ["!Try again."]
- )
-
- "!!Calculating..."
- 1 s :
- (
- 500 x. - s. * ^
- x. 1 - x. 1 - * x. x. * + w :
- 1 t :
- x. 1 + y :
- (
- 500 y. - t. * ^
- y. y. * z :
- z. w. < [ 1 y. + y : ]
- z. w. > [ 0 t : ]
- z. w. = [ 0 t : 0 s : ]
- )
- s.
- [1 x. + x : ]
- )
- s. 0 =
- [
- "!!
- The man lives in the " x. ! "th house.
- His house number is " x. 2 * 1 - !".
- There are " y. !" houses.
- "
- ]
- s.
- ["!!Try a smaller x."]
- $
- the " x. ! "th house.
- His house number is " x. 2 * 1 - !".
- The