Blame


1 12687dd9 2023-08-04 jrmu ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 12687dd9 2023-08-04 jrmu ;; about the language level of this file in a form that our tools can easily process.
3 12687dd9 2023-08-04 jrmu #reader(lib "htdp-intermediate-lambda-reader.ss" "lang")((modname |26.3|) (read-case-sensitive #t) (teachpacks ((lib "draw.ss" "teachpack" "htdp") (lib "arrow.ss" "teachpack" "htdp") (lib "gui.ss" "teachpack" "htdp"))) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ((lib "draw.ss" "teachpack" "htdp") (lib "arrow.ss" "teachpack" "htdp") (lib "gui.ss" "teachpack" "htdp")))))
4 12687dd9 2023-08-04 jrmu ;gcd-structural : N[>=1] N[>=1] -> N
5 12687dd9 2023-08-04 jrmu ;Determine the greatest common divisor between n and m by testing every number between 1 and (min m n), starting at (min m n).
6 12687dd9 2023-08-04 jrmu
7 12687dd9 2023-08-04 jrmu (define (gcd-structural m n)
8 12687dd9 2023-08-04 jrmu (check-divisible (min m n)))
9 12687dd9 2023-08-04 jrmu
10 12687dd9 2023-08-04 jrmu ;check-divisible : N[>=1] -> N
11 12687dd9 2023-08-04 jrmu Given x, check to see if m and n are divisible by x. m and n are passed into check-divisible by a binding variable outside of check-divisible.
12 12687dd9 2023-08-04 jrmu
13 12687dd9 2023-08-04 jrmu (define (check-divisible x)
14 12687dd9 2023-08-04 jrmu (cond
15 12687dd9 2023-08-04 jrmu [(= x 1) 1]
16 12687dd9 2023-08-04 jrmu []))