about summary refs log tree commit diff
path: root/others/mHoang/pfactor.scm
blob: 4e3bd17039cb60915144ab619f4dbb006600ceb4 (plain) (blame)
1
2
3
4
5
6
7
8
9
(define (div dividend divisor)
  (if (= (remainder dividend divisor) 0)
      (div (/ dividend divisor) divisor)
      dividend))
(display (let* ((n (read)) (s (exact-integer-sqrt n)))
           (do ((i 2 (+ i 1)))
               ((or (= (div n i) 1) (> i s)) (if (> i s) n i))
             (set! n (div n i)))))
(newline)