Blob


1 ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 ;; about the language level of this file in a form that our tools can easily process.
3 #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 ;add : N -> inexact
5 ;Adds up #i1/185 n times.
7 (define (add n)
8 (cond
9 [(= n 1) #i1/185]
10 [else (+ #i1/185 (add (sub1 n)))]))
12 ;sub : inexact or number N -> N
13 ;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.
15 (define (sub n0)
16 (local ((define (sub-accu n1 accumulator)
17 (cond
18 [(<= n1 0) accumulator]
19 [else (sub-accu (- n1 1/185) (add1 accumulator))])))
20 (sub-accu n0 0)))