<a href="http://projecteuler.net/index.php?section=problems&id=188">Problem 188</a>
タワー表記かよ. 実はあっさり解ける問題.
(define (find a b n) (define (order a n) (let loop ((i 1) (c a)) (if (= c 1) i (loop (+ i 1) (remainder (* c a) n))))) (if (= b 1) (remainder a n) (let1 o (order a n) (expt-mod a (find a (- b 1) o) n)))) ;(time (find 1777 1855 (expt 10 8))) ; real 1.938 ; user 1.719 ; sys 0.219