예제 #1
0
def run():
    maximum = 999
    palindrome = -1
    i = maximum
    while i > 0 and palindrome == -1:
        j = 0
        while i+j <= maximum-j:
            if euler.isPalindrome((i+j)*(maximum-j)):
                palindrome = (i+j)*(maximum-j)
            j += 1
        i -= 1
    return palindrome
예제 #2
0
def run():
    matches = set([])
    limit = 10**8
    for i in xrange(1, 7071):
        j = 2
        while True:
            n = sumNConsecutiveSquares(i, j)
            if n >= limit:
                break
            if euler.isPalindrome(n):
                matches.add(n)
            j += 1
    return sum(matches)
예제 #3
0
from euler import isPalindrome
output = 0
m = 0
n = 0
for i in range(999, 100, -1):
    for j in range(999, 100, -1):
        result = i * j
        if isPalindrome(result):
            if output < result:
                output = result
                m = i
                n =j
print output, m, n
예제 #4
0
from euler import isPalindrome
output = 0
m = 0
n = 0
for i in range(999, 100, -1):
    for j in range(999, 100, -1):
        result = i * j
        if isPalindrome(result):
            if output < result:
                output = result
                m = i
                n = j
print output, m, n
예제 #5
0
def isLychrel(n):
    for _ in range(1, 51):
        n = reverseAndAdd(n)
        if euler.isPalindrome(n):
            return False
    return True
예제 #6
0
def isPalindrome(n):
    ''' Determine if n is a palindrome. '''
    digits = euler.digitize(n)
    return euler.isPalindrome(digits)
예제 #7
0
def isLychrel(num):
    for i in range(0, 50):
        num += int(str(num)[::-1])
        if e.isPalindrome(str(num)):
            return True
    return False