M.Suzuki #7640(2008/09/17 02:06 GMT) [ Haskell ] Rating0/0=0.00
軽く候補の絞込み(2と3と5の倍数しか回答は無いので)を入れてみました。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
list max b n | (b^n) > max = [] | otherwise = n : list max b (n+1) scan n = [(n,i,j,k)|i<-list n 2 0,j<-list n 3 0,k<-list n 5 0,n == (2^i*3^j*5^k)] result = take 100 $ concatMap (scan) $ filter (check) [1..] check n | n == 1 = True | (n `mod` 2) == 0 = True | (n `mod` 3) == 0 = True | (n `mod` 5) == 0 = True | otherwise = False main=do mapM (\x-> putStrLn $ format x) result where format (n,i,j,k) = concat [show n," = ",fmt 2 i," * ",fmt 3 j," * ",fmt 5 k] fmt b n = show b ++ "^" ++ show n
Rating0/0=0.00-0+
[ reply ]
M.Suzuki #7640() [ Haskell ] Rating0/0=0.00
Rating0/0=0.00-0+
[ reply ]