Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (define (iterate start-value next-value start-index next-index finished?)
- (define (inner-iter cur-val cur-index)
- (if (finished? cur-val cur-index)
- cur-val
- (inner-iter (next-value cur-val cur-index) (next-index cur-val cur-index))))
- (inner-iter start-value start-index))
- ; b)
- (define (phi n)
- (if (= n 0)
- 1.0
- (iterate
- 1.0 (lambda (cur-val cur-index) (+ 1 (/ 1 cur-val))) ; Start-Wert und Werteberechnung (1+1/vorherigen wert)
- 0 (lambda (cur-val cur-index) (+ cur-index 1)) ; Start-Index und Indexerhöhung (index++)
- (lambda (cur-val cur-index) (if (= n cur-index) #t #f)) ; Endabfrage (index == n)
- )))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement