http://projecteuler.net/index.php?section=problems&id=130

前問の結果を使えば、楽。

{-# OPTIONS_GHC -XBangPatterns #-}
import Number
count n = count' n (,100) 1
count' n (q,r) !k | gcd 10 n /= 1 = n
| (q,r)==(,10) = k
| otherwise = count' n (divMod (10*r) (9*n))$ k+1
valid n | mod (n-1) (count n) ==  = True
| otherwise = False
main = print.sum.take 25.filter valid$nonprimes