fork download
  1. import Data.List
  2.  
  3. count n = foldl (\i j-> i + div n j) 0 [1..sq] * 2 - (sq^2) -- 積がn以下になる自然数の順序対の個数
  4. where sq = floor $ sqrt $ fromIntegral n
  5.  
  6. f 0 = 0
  7. f m = f (m-1) + count (m^2 `div` 4)
  8.  
  9.  
Success #stdin #stdout 0.44s 4780KB
stdin
20
67
125
1879
2615
3000
stdout
3032
167672
1280414
7291768620
20635666540
31773763314