; compatible numbers

(define (reducible? g x)
  (let ((d (gcd g x)))
    (if (= d 1) #f
      (if (= d x) #t
        (reducible? g (/ x d))))))

(define (compatible? a b)
  (if (= a b) #t
    (if (or (= a 1) (= b 1)) #f
      (let ((g (gcd a b)))
        (if (= g 1) #f
          (and (reducible? g a)
               (reducible? g b)))))))

(display (compatible? 15 75)) (newline)
(display (compatible? (* 2 3 5 7 11) (* 2 3 5 7 11 13))) (newline)
(display (compatible? (* 2 3 5 7) (* 2 2 3 3 3 5 5 5 5 5 7 7 7 7 7 7 7))) (newline)