Return to Snippet

Revision: 27071
at May 21, 2010 10:36 by chroto


Initial Code
#!/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

Initial URL


Initial Description


Initial Title
Project Euler - Problem 4

Initial Tags


Initial Language
Python