/ Published in: Python
                    
                                        
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
#!/usr/bin/python
print "\nProject Euler - Problem 4"
print "This program finds the largest"
print "palindrome made from the product"
print "of two 3-digit numbers.\n"
import array
facta = 999
factb = 999
test = 1
ans = 0
maximum = 0
while facta > 99:
while factb > 99:
num = facta * factb
ans = str(num) + '$'
x = array.array('c', ans[0:-1]).tolist()
y = array.array('c', ans[0:-1]).tolist()
x.reverse()
if (y == x):
if (maximum < num):
maximum = num
factb = factb - 1
facta = facta - 1
factb = 999
print 'result = %s' % maximum
Comments
 Subscribe to comments
                    Subscribe to comments
                
                