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.
速く動かすのに、意外と手こずった。ポイントは11で割れることか。
p004 = head [p|a<-[9,8..1],b<-[9,8..],c<-[9,8..],p<-[100001*a+10010*b+1100*c],q<-factors p,q>99,q<=999] where factors x= [div x n|n<-[990,979..110],x `mod` n ==] -- 100001*a+10010*b+1100*c=11*(9091*a + 910*b + 100*c)
作成者 Toru Mano
最終更新時刻 2023-01-01 (c70d5a1)