Problem 4
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 * 99.
Find the largest palindrome made from the product of two 3-digit numbers.
訳
「回文数」とは右から読んでも左からでも同じである数である.二桁の数の積で作られる,もっとも大きい回文数は9009 = 91 * 90である.
三桁の数の積で作られる最大の回文数を求めよ.
妙にシンプルで気持ち悪いですが,100から999までの数同士の積を全部作って,ひっくり返して一致するものを作って,最大値を求めればよいのでしょうが,何か裏がありそうだなあ.
[Haskell] 素直にとく
掛け算は順序は関係ないので,半分だけの計算で済みます.
{- e4.hs Project Euler Ploblem 4 -} f::[Int] f = filter (\y -> (reverse.show) y == show y ) [ i*j | i <- [100..999], j<-[100..999], i<=j] main = (putStr.show.maximum) f
C:\euler>ghc e4.hs -o e4 C:\euler>e4 906609