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-reader.ss" "lang")((modname |23.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 #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 ;sqr-term : N[>=0] -> number
5 12687dd9 2023-08-04 jrmu ;Given n, maps n to the n-th term of a sequence, in this case, sqr-term.
6 12687dd9 2023-08-04 jrmu
7 12687dd9 2023-08-04 jrmu (define (sqr-term n)
8 12687dd9 2023-08-04 jrmu (sqr n))
9 12687dd9 2023-08-04 jrmu
10 12687dd9 2023-08-04 jrmu ;series : (number -> number) [N>=0] -> number
11 12687dd9 2023-08-04 jrmu ;Given a nth-term and n, sums up the first n terms of the series.
12 12687dd9 2023-08-04 jrmu (define (series nth-term n)
13 12687dd9 2023-08-04 jrmu (cond
14 12687dd9 2023-08-04 jrmu [(zero? n) (nth-term n)]
15 12687dd9 2023-08-04 jrmu [else (+ (nth-term n)
16 12687dd9 2023-08-04 jrmu (series nth-term (sub1 n)))]))