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-advanced-reader.ss" "lang")((modname |33.1|) (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 #t #t none #f ((lib "draw.ss" "teachpack" "htdp") (lib "arrow.ss" "teachpack" "htdp") (lib "gui.ss" "teachpack" "htdp")))))
4 12687dd9 2023-08-04 jrmu ;add : N -> inexact
5 12687dd9 2023-08-04 jrmu ;Adds up #i1/185 n times.
6 12687dd9 2023-08-04 jrmu
7 12687dd9 2023-08-04 jrmu (define (add n)
8 12687dd9 2023-08-04 jrmu (cond
9 12687dd9 2023-08-04 jrmu [(= n 1) #i1/185]
10 12687dd9 2023-08-04 jrmu [else (+ #i1/185 (add (sub1 n)))]))
11 12687dd9 2023-08-04 jrmu
12 12687dd9 2023-08-04 jrmu sub : inexact or number N -> N
13 12687dd9 2023-08-04 jrmu Determines the number of times that 1/185 can be subtracted from n0. The accumulator represents the number of times that 1/185 has been subtracted from n0 to give n1.
14 12687dd9 2023-08-04 jrmu
15 12687dd9 2023-08-04 jrmu (define (sub n0)
16 12687dd9 2023-08-04 jrmu (local ((define (sub-accu n1 accumulator)
17 12687dd9 2023-08-04 jrmu (cond
18 12687dd9 2023-08-04 jrmu [(zero? n) ...]
19 12687dd9 2023-08-04 jrmu [else ...])))
20 12687dd9 2023-08-04 jrmu (sub n0 ...)))