Problem 234
コンテンツ
234 Semidivisible numbers
prime sqaure root という,素数の世界でのルートについての問題.
lps, ups が決まると範囲が決まるので,それを利用.
import Number (primes) p234 :: Integer -> Integer p234 n = sum.filter ( <= n ).concat.zipWith semiIn (takeWhile (<= u) primes) $ tail primes where u = floor.sqrt.fromIntegral $ n semiIn :: (Num a, Enum a) => a -> a -> [a] semiIn l u = filter ( /= l * u ) $ semiL ++ semiU where semiL = [l * (l+1), l * (l+2)..u * u - 1] semiU = reverse [u * (u-1), u * (u-2)..l * l + 1] main :: IO () main = print.p234 $ 999966663333
作成者 Toru Mano
最終更新時刻 2023-01-01 (c70d5a1)