(use srfi-27) (define (output-solution p q) (begin (display "! ") (display p) (display " ") (display q) (newline) (flush))) (define n (read)) (define (itr) (let* ((a (+ (random-integer (- n 3)) 2)) (b (gcd n a))) (if (not (= b 1)) (output-solution b (/ n b)) (begin (display "? ") (display a) (newline) (flush) (let1 r (read) (if (odd? r) (itr) (let1 x (expt-mod a (/ r 2) n) (if (= x (- n 1)) (itr) (let1 p (gcd n (+ x 1)) (output-solution p (/ n p))))))))))) (itr)