Advertisement
PonaFly

Untitled

Dec 20th, 2018
879
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scheme 0.46 KB | None | 0 0
  1. (define (Poisk 1arg 2arg)
  2.   (define (ostatok x z n)
  3.     (if (or (= 1 x) (= 1 z)) 1
  4.     (if (> n (or x z)) #f
  5.         (if (and (= 0 (remainder x n)) (= 0 (remainder z n))) n
  6.             (ostatok x z (+ 1 n))))))
  7.   (ostatok 1arg 2arg 2))
  8.  
  9.  
  10.  
  11. (define (help arg n z)
  12.   (if (= n arg) z
  13.       (if (= 0 (remainder arg n)) (help arg (+ 1 n) (cons n z))
  14.           (help arg (+ 1 n) z))))
  15. (define (perfect X)
  16.   (if (= 0 X) #f
  17.   (if (= X (apply + (help X 1 '()))) #t #f)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement