Mystery längs 26:an #225

Mystery längs 26:an #225

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
for i in range(0, 1291467969):  # 1.000.000 i bas 33
    base33 = number2base(i, 33)
    if base33 == base33[::-1]:
        j += 1
        print(str(j) + " " + base33)
print("Antal: " + str(j) + " eller " + number2base(j, 33) + " i bas 33")