Exemplo n.º 1
0
def find_dec_bin_pal_sum(N):
    cur_sum = 0

    for ii in range(N):
        if (ii%2==1):
            if mwmath.is_pal(ii):
                b = str(bin(ii))
                if mwmath.is_pal(b[2:len(b)]):
                    cur_sum+=ii

    return cur_sum
Exemplo n.º 2
0
def is_Lychrel(n):

    n_flips = 0

    while n_flips<51:

        n = reverse_and_add(n)
        n_flips+=1

        if mwmath.is_pal(n):
            return False

    return True
Exemplo n.º 3
0
def is_Lychrel(n):

    n_flips = 0

    while n_flips < 51:

        n = reverse_and_add(n)
        n_flips += 1

        if mwmath.is_pal(n):
            return False

    return True
Exemplo n.º 4
0
import math
import mwmath
import time

s = time.time()

N = 1000000
cur_sum = 0

for ii in range(N):
    if (ii%2==1):
        if mwmath.is_pal(ii):
            b = str(bin(ii))
            if mwmath.is_pal(b[2:len(b)]):
                cur_sum+=ii

print cur_sum

print time.time()-s