Start of topic | Skip to actions

Solution: hypotenuse

; square : number -> number
; Returns the square of the input.
(define (square n)
  (* n n))

'square_examples
(= (square 0) 0)
(= (square 2) 4)
(= (square 3) 9)
(= (square 5) 25)




; hypotenuse : real real -> positive-real
; Returns the length of the hypotenuse of a right triangle having
; the given height and width.
(define (hypotenuse height width)
  (sqrt (+ (square height) (square width))))

'hypotenuse_examples
(= (hypotenuse 0 0) 0)
(= (hypotenuse 3 4) 5)
(= (hypotenuse 6 8) 10)

Access Permissions


End of topic
Skip to actions | Back to top
Creative Commons LicenseThis work is licensed under a Creative Commons Attribution 2.5 License. Please follow our citation guidelines.