Advertisement
Guest User

Untitled

a guest
Dec 19th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scheme 0.51 KB | None | 0 0
  1. (define (isprimeimpl x y)
  2.     (or (= y 0)
  3.       (and (not (= (mod x (+ y 1)) 0)) (isprimeimpl x (- y 1)))
  4.     )
  5. )
  6.  
  7. (define (isprime x)
  8.   (isprimeimpl x (- x 2))
  9. )
  10.  
  11. (define (test x)
  12.   (or (and x 1) 0))
  13.  
  14. (define (sumOfPrimeDivsImpl y c)
  15.   (if (= c 1)
  16.     0
  17.     (+
  18.       (* (* (- y c) (test (isprime (- y c)))) (test (= (mod y (- y c)) 0)))
  19.       (sumOfPrimeDivsImpl y (- c 1))))
  20. )
  21.  
  22. (define (sumOfPrimeDivs y)
  23.   (sumOfPrimeDivsImpl y y)
  24. )
  25.  
  26. (define (R y x)
  27.   (and
  28.     (not (= y 0))
  29.     (< (sumOfPrimeDivs y) x)
  30.   ))
  31.  
  32. (R 10 8)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement