首页 > 其他 > 详细

projecteuler---->problem=4----Largest palindrome product

时间:2014-06-07 01:18:11      阅读:284      评论:0      收藏:0      [点我收藏+]

title:

Largest palindrome product

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 bubuko.com,布布扣 99.

Find the largest palindrome made from the product of two 3-digit numbers.

翻译;

假如一个数前后掉转后还是同一个数的话,那个数就叫做「回文数」。由两个二位数的积构成的最大回文数是9009 = 91 × 99。

请找出由两个三位数的积构成的最大回文数。

解答:

def isOk(a):
	n=0
	b=[0]*100
	while a>0:
		b[n]=a%10
		a /= 10
		n += 1
	for i in range(n//2):
		if b[i]!=b[n-i-1]:
			return False	
	return True

m=0
for i in range(100,999):
	for j in range(100,999):
		if isOk(i*j) :
			if i*j > m:
				m = i*j;

print m 



projecteuler---->problem=4----Largest palindrome product,布布扣,bubuko.com

projecteuler---->problem=4----Largest palindrome product

原文:http://blog.csdn.net/china_zoujinyong/article/details/27342161

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!