Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (define (number->list n)
- (letrec
- ((convert (lambda (x l)
- (if (= x 0)
- l
- (convert (truncate (/ x 10)) (cons (inexact->exact (modulo x 10)) l))
- )
- )
- ))
- (convert (exact->inexact n) '())
- )
- )
- (define (fold f null l)
- (if (eq? l '())
- null
- (fold f (f (car l) null) (cdr l))))
- (define (multiple-de-3 n)
- (if (or (= n 3) (= n 6) (= n 9))
- #t
- (if (< n 9)
- #f
- (multiple-de-3 (fold + 0 (number->list n)))
- )
- )
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement