fork download
  1. ; compatible numbers
  2.  
  3. (define (reducible? g x)
  4. (let ((d (gcd g x)))
  5. (if (= d 1) #f
  6. (if (= d x) #t
  7. (reducible? g (/ x d))))))
  8.  
  9. (define (compatible? a b)
  10. (if (= a b) #t
  11. (if (or (= a 1) (= b 1)) #f
  12. (let ((g (gcd a b)))
  13. (if (= g 1) #f
  14. (and (reducible? g a)
  15. (reducible? g b)))))))
  16.  
  17. (display (compatible? 15 75)) (newline)
  18. (display (compatible? (* 2 3 5 7 11) (* 2 3 5 7 11 13))) (newline)
  19. (display (compatible? (* 2 3 5 7) (* 2 2 3 3 3 5 5 5 5 5 7 7 7 7 7 7 7))) (newline)
Success #stdin #stdout 0.03s 8616KB
stdin
Standard input is empty
stdout
#t
#f
#t