Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Задание 1:
- (define mdig (lambda (x)
- (if (< x 10)
- x
- (if (< (remainder x 10) (mdig (quotient x 10))) (remainder x 10) (mdig (quotient x 10))) ))
- )
- Задание 2:
- (define (eqdig x)
- (define eqdig_raw (lambda (x)
- (if (< x 10)
- x
- (if (eq? (remainder x 10) (eqdig_raw (quotient x 10))) (remainder x 10) #f) )))
- (if (eq? (eqdig_raw x) #f) #f #t)
- )
- Задание 3:
- (define (fact? max)
- (define fact (lambda (n x max)
- (if (= max x)
- (- n 1)
- (if (> x max) #f (fact (+ n 1) (* x n) max)))) )
- (fact 1 1 max)
- )
- Задание 4:
- (define (findFib x)
- (define (find x a b c)
- (if (> (+ b c) x)
- (if (< (- x c) (- (+ b c) x)) c (+ b c)
- )
- (find x b c (+ c b)) )
- )
- (find x 1 1 2) )
- Задание 5:
- (define (perfect x)
- (define (temp x S d)
- (if (and (= S x) (= x d) )
- #t
- (if (= (remainder x d) 0)
- (temp x (+ S d) (+ d 1))
- (if (< d x)
- (temp x S (+ d 1))
- #f)
- )
- ))
- (temp x 0 1) )
- (define (perfect x)
- (define (temp x del sum)
- (if (= x 1)
- #f
- (if (= x sum)
- #t
- (if (< (* del del) x)
- (if (= (remainder x del) 0)
- (temp x (+ del 1) (+ sum del (/ x del)))
- (temp x (+ del 1) sum)
- )
- #f
- )
- )
- )
- )
- (temp x 2 1)
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement