Problem 80

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

どっかで調べた開平法を実装。

探索範囲が狭いから楽。

import Data.List
root m =root' m 0
root' n a = b : root' n' a'
where b  = head ,(a+c)*c < n]
n' = (n-(a+b)*b)*100
a' = (a+2*b)*10
p080 = sum.map (sum.take 100.root).(\\) [2..99]$map(^2)[2..9]
More Reading
Newer// Problem 79
Older// Problem 81