Mystery längs 26:an #229

Mystery längs 26:an #229

def number2base(x, base):
    digs = "0123456789abcdefghijklmnopqrstuvwxyz"
    if x == 0:
        return digs[0]
    digits = []
    while x:
        digits.append(digs[x % base])
        x = x // base
    digits.reverse()
    return ''.join(digits)


j = 0
summa = 0
for i in range(22, 10786956):
    if number2base(i, 22) == number2base(i, 22)[::-1]:
        j += 1
        summa += i
        print(str(j) + ": " + number2base(i, 22))
print("Antal: " + str(j))
print("Summa: " + str(summa))
print("Antal i bas 22: " + number2base(j, 22))
print("Summa i bas 22: " + number2base(summa, 22))