22a. Feb.G Review
- Trace the execution of
(snow 300)
.
(define (snow n)
(cond [(= 2 (remainder n 3))
(quotient n 6)]
[(< 50 n)
(add1 (snow (quotient n 2)))]
[else
(+ 5 (snow (- n 4)))]))
- (
tall-tree
) Make ann
layer stack of green triangles and put a brown rectangle at the bottom.
-
(
cr7 : integer(avoid) -> number
) How many multiples of 7 are there fromavoid
up to 1000? Except do not count any multiple ofavoid
.(Math-only solutions discouraged; practice recursion. Will your solution also work to avoid odd numbers as well as multiples of
avoid
?)Examples:
(cr7 3) => 95 (cr7 10) => 127
-
(
big-gap? : positive-integer(n) -> boolean
) True ifn
has two adjacent groups of two digits that differ by more than fifty.Examples:
(big-gap? 1030) => false (big-gap? 2080) => true (big-gap? 123456) => false (big-gap? 142958) => true (big-gap? 190) => false
Note that in the last example, there are not two adjacent groups of two digits.