problem 52
x, 2x, 3x, 4x, 5x, 6x が全て同じ数字の組み合わせになる正数 x を求める問題です。
(use srfi-1) (use util.stream) (define integer (stream-cons 1 (stream-map (pa$ + 1) integer))) ; 14235 -> '(1 2 3 4 5) (define (digits n) (let loop ((n n) (r '())) (if (= n 0) (sort r) (loop (quotient n 10) (cons (modulo n 10) r))))) (define (same-digits? n) (apply list= (cons eq? (map (compose digits (pa$ * n)) (iota 6 1))))) (define (p52) (stream-find same-digits? (stream-cdr integer))) (print (p52))