# Find all numbers between 1 to 10,000 which are palindromes in more than one base def digit_to_char(digit): if digit < 10: return str(digit) return chr(ord('a') + digit - 10) def str_base(number,base): if number < 0: return '-' + str_base(-number, base) (d, m) = divmod(number, base) if d > 0: return str_base(d, base) + digit_to_char(m) return digit_to_char(m) for S in range(1, 10001): n = 0 S += 1 palindromeCount = 0 msg = "" for B in range(2,11): inBaseB = str_base(S, B) if inBaseB == inBaseB[::-1]: msg += " base " + str(B) + ": " + inBaseB + ";" palindromeCount += 1 if palindromeCount >= 2: print(str(S) + "(" + msg + " )")

2( base 3: 2; base 4: 2; base 5: 2; base 6: 2; base 7: 2; base 8: 2; base 9: 2; base 10: 2; ) 3( base 2: 11; base 4: 3; base 5: 3; base 6: 3; base 7: 3; base 8: 3; base 9: 3; base 10: 3; ) 4( base 3: 11; base 5: 4; base 6: 4; base 7: 4; base 8: 4; base 9: 4; base 10: 4; ) 5( base 2: 101; base 4: 11; base 6: 5; base 7: 5; base 8: 5; base 9: 5; base 10: 5; ) 6( base 5: 11; base 7: 6; base 8: 6; base 9: 6; base 10: 6; ) 7( base 2: 111; base 6: 11; base 8: 7; base 9: 7; base 10: 7; ) 8( base 3: 22; base 7: 11; base 9: 8; base 10: 8; ) 9( base 2: 1001; base 8: 11; base 10: 9; ) 10( base 3: 101; base 4: 22; base 9: 11; ) 15( base 2: 1111; base 4: 33; ) 16( base 3: 121; base 7: 22; ) 17( base 2: 10001; base 4: 101; ) 18( base 5: 33; base 8: 22; ) 20( base 3: 202; base 9: 22; ) 21( base 2: 10101; base 4: 111; base 6: 33; ) 24( base 5: 44; base 7: 33; ) 26( base 3: 222; base 5: 101; ) 27( base 2: 11011; base 8: 33; ) 28( base 3: 1001; base 6: 44; ) 31( base 2: 11111; base 5: 111; ) 33( base 2: 100001; base 10: 33; ) 36( base 5: 121; base 8: 44; ) 40( base 3: 1111; base 7: 55; base 9: 44; ) 45( base 2: 101101; base 8: 55; ) 46( base 4: 232; base 5: 141; ) 50( base 7: 101; base 9: 55; ) 51( base 2: 110011; base 4: 303; ) 52( base 3: 1221; base 5: 202; ) 55( base 4: 313; base 6: 131; base 10: 55; ) 57( base 5: 212; base 7: 111; ) 63( base 2: 111111; base 4: 333; base 8: 77; ) 65( base 2: 1000001; base 4: 1001; base 8: 101; ) 67( base 5: 232; base 6: 151; ) 73( base 2: 1001001; base 8: 111; ) 78( base 5: 303; base 7: 141; ) 80( base 3: 2222; base 6: 212; base 9: 88; ) 82( base 3: 10001; base 9: 101; ) 85( base 2: 1010101; base 4: 1111; base 7: 151; ) 88( base 5: 323; base 10: 88; ) 91( base 3: 10101; base 9: 111; ) 92( base 6: 232; base 7: 161; ) 93( base 2: 1011101; base 5: 333; ) 98( base 5: 343; base 6: 242; ) 99( base 2: 1100011; base 10: 99; ) 100( base 3: 10201; base 7: 202; base 9: 121; ) 104( base 5: 404; base 6: 252; ) 105( base 4: 1221; base 8: 151; ) 107( base 2: 1101011; base 7: 212; ) 109( base 5: 414; base 9: 131; ) 111( base 6: 303; base 10: 111; ) 114( base 5: 424; base 7: 222; ) 119( base 2: 1110111; base 5: 434; ) 121( base 3: 11111; base 7: 232; base 8: 171; base 10: 121; ) 127( base 2: 1111111; base 9: 151; ) 129( base 2: 10000001; base 6: 333; ) 130( base 3: 11211; base 4: 2002; base 8: 202; ) 135( base 6: 343; base 7: 252; ) 141( base 6: 353; base 10: 141; ) 142( base 3: 12021; base 7: 262; ) 150( base 4: 2112; base 7: 303; ) 151( base 3: 12121; base 10: 151; ) 154( base 6: 414; base 8: 232; base 9: 181; ) 160( base 3: 12221; base 6: 424; ) 164( base 3: 20002; base 7: 323; base 9: 202; ) 170( base 4: 2222; base 8: 252; ) 171( base 7: 333; base 10: 171; ) 173( base 3: 20102; base 9: 212; ) 178( base 6: 454; base 7: 343; base 8: 262; ) 182( base 3: 20202; base 9: 222; ) 185( base 6: 505; base 7: 353; ) 186( base 5: 1221; base 8: 272; ) 191( base 6: 515; base 9: 232; base 10: 191; ) 195( base 2: 11000011; base 4: 3003; base 8: 303; ) 200( base 7: 404; base 9: 242; ) 203( base 3: 21112; base 6: 535; base 8: 313; ) 209( base 6: 545; base 9: 252; ) 212( base 3: 21212; base 10: 212; ) 215( base 4: 3113; base 6: 555; ) 219( base 2: 11011011; base 8: 333; ) 227( base 8: 343; base 9: 272; ) 235( base 4: 3223; base 7: 454; base 8: 353; ) 242( base 3: 22222; base 7: 464; base 10: 242; ) 246( base 5: 1441; base 9: 303; ) 252( base 5: 2002; base 10: 252; ) 255( base 2: 11111111; base 4: 3333; base 9: 313; ) 257( base 2: 100000001; base 4: 10001; base 7: 515; ) 264( base 7: 525; base 9: 323; ) 273( base 2: 100010001; base 4: 10101; base 9: 333; ) 282( base 5: 2112; base 9: 343; base 10: 282; ) 292( base 7: 565; base 8: 444; base 10: 292; ) 300( base 7: 606; base 8: 454; base 9: 363; ) 313( base 2: 100111001; base 10: 313; ) 316( base 3: 102201; base 8: 474; ) 325( base 2: 101000101; base 4: 11011; base 8: 505; ) 328( base 3: 110011; base 7: 646; base 9: 404; ) 333( base 8: 515; base 10: 333; ) 341( base 2: 101010101; base 4: 11111; base 8: 525; ) 342( base 5: 2332; base 7: 666; ) 343( base 6: 1331; base 10: 343; ) 357( base 4: 11211; base 8: 545; ) 364( base 3: 111111; base 9: 444; ) 365( base 2: 101101101; base 8: 555; ) 373( base 4: 11311; base 8: 565; base 9: 454; base 10: 373; ) 381( base 2: 101111101; base 8: 575; ) 393( base 4: 12021; base 10: 393; ) 400( base 3: 112211; base 7: 1111; base 9: 484; ) 414( base 8: 636; base 10: 414; ) 427( base 2: 110101011; base 6: 1551; ) 434( base 6: 2002; base 10: 434; ) 438( base 5: 3223; base 8: 666; ) 446( base 8: 676; base 9: 545; ) 455( base 2: 111000111; base 8: 707; base 9: 555; ) 464( base 9: 565; base 10: 464; ) 471( base 2: 111010111; base 8: 727; ) 484( base 3: 122221; base 10: 484; ) 495( base 2: 111101111; base 8: 757; ) 511( base 2: 111111111; base 8: 777; ) 513( base 2: 1000000001; base 8: 1001; ) 546( base 4: 20202; base 9: 666; ) 555( base 9: 676; base 10: 555; ) 560( base 3: 202202; base 6: 2332; ) 564( base 5: 4224; base 9: 686; ) 585( base 2: 1001001001; base 8: 1111; base 10: 585; ) 624( base 5: 4444; base 7: 1551; ) 626( base 5: 10001; base 10: 626; ) 644( base 3: 212212; base 6: 2552; ) 646( base 9: 787; base 10: 646; ) 651( base 5: 10101; base 6: 3003; ) 656( base 3: 220022; base 9: 808; base 10: 656; ) 666( base 4: 22122; base 10: 666; ) 676( base 5: 10201; base 10: 676; ) 692( base 3: 221122; base 9: 848; ) 693( base 2: 1010110101; base 6: 3113; ) 701( base 5: 10301; base 9: 858; ) 717( base 2: 1011001101; base 10: 717; ) 728( base 3: 222222; base 9: 888; ) 730( base 3: 1000001; base 9: 1001; ) 757( base 3: 1001001; base 10: 757; ) 771( base 2: 1100000011; base 4: 30003; ) 777( base 6: 3333; base 10: 777; ) 787( base 4: 30103; base 10: 787; ) 819( base 2: 1100110011; base 4: 30303; base 6: 3443; ) 820( base 3: 1010101; base 9: 1111; ) 856( base 5: 11411; base 7: 2332; ) 868( base 6: 4004; base 10: 868; ) 910( base 3: 1020201; base 6: 4114; base 9: 1221; ) 939( base 4: 32223; base 10: 939; ) 975( base 2: 1111001111; base 4: 33033; ) 1023( base 2: 1111111111; base 4: 33333; ) 1025( base 2: 10000000001; base 4: 100001; ) 1066( base 3: 1110111; base 5: 13231; ) 1105( base 2: 10001010001; base 4: 101101; ) 1221( base 5: 14341; base 10: 1221; ) 1285( base 2: 10100000101; base 4: 110011; ) 1312( base 3: 1210121; base 7: 3553; ) 1365( base 2: 10101010101; base 4: 111111; ) 1432( base 5: 21212; base 7: 4114; ) 1441( base 6: 10401; base 10: 1441; ) 1460( base 3: 2000002; base 9: 2002; ) 1539( base 2: 11000000011; base 8: 3003; ) 1550( base 3: 2010102; base 9: 2112; ) 1640( base 3: 2020202; base 9: 2222; ) 1667( base 3: 2021202; base 5: 23132; ) 1755( base 2: 11011011011; base 8: 3333; ) 1885( base 4: 131131; base 6: 12421; ) 2000( base 7: 5555; base 9: 2662; ) 2188( base 3: 10000001; base 5: 32223; ) 2268( base 5: 33033; base 8: 4334; ) 2293( base 5: 33133; base 6: 14341; ) 2550( base 4: 213312; base 9: 3443; ) 2565( base 2: 101000000101; base 8: 5005; ) 2709( base 2: 101010010101; base 5: 41314; base 8: 5225; ) 2730( base 4: 222222; base 9: 3663; ) 2910( base 4: 231132; base 9: 3883; ) 2920( base 3: 11000011; base 9: 4004; ) 2925( base 2: 101101101101; base 8: 5555; ) 2997( base 7: 11511; base 8: 5665; ) 3069( base 2: 101111111101; base 8: 5775; ) 3074( base 5: 44244; base 6: 22122; ) 3075( base 2: 110000000011; base 4: 300003; ) 3280( base 3: 11111111; base 9: 4444; ) 3315( base 2: 110011110011; base 4: 303303; ) 3550( base 7: 13231; base 9: 4774; ) 3591( base 2: 111000000111; base 8: 7007; ) 3640( base 3: 11222211; base 9: 4884; ) 3663( base 8: 7117; base 10: 3663; ) 3735( base 2: 111010010111; base 8: 7227; ) 3740( base 6: 25152; base 9: 5115; ) 3855( base 2: 111100001111; base 4: 330033; ) 3951( base 2: 111101101111; base 8: 7557; ) 3999( base 2: 111110011111; base 6: 30303; ) 4095( base 2: 111111111111; base 4: 333333; base 8: 7777; ) 4097( base 2: 1000000000001; base 4: 1000001; base 8: 10001; ) 4161( base 2: 1000001000001; base 4: 1001001; base 8: 10101; ) 4225( base 4: 1002001; base 8: 10201; ) 4257( base 2: 1000010100001; base 6: 31413; ) 4289( base 4: 1003001; base 8: 10301; ) 4369( base 2: 1000100010001; base 4: 1010101; ) 4433( base 2: 1000101010001; base 4: 1011101; ) 4593( base 2: 1000111110001; base 6: 33133; ) 4617( base 2: 1001000001001; base 8: 11011; ) 4681( base 2: 1001001001001; base 8: 11111; ) 5001( base 6: 35053; base 8: 11611; ) 5049( base 2: 1001110111001; base 7: 20502; ) 5125( base 2: 1010000000101; base 4: 1100011; ) 5189( base 2: 1010001000101; base 4: 1101011; ) 5397( base 2: 1010100010101; base 4: 1110111; ) 5461( base 2: 1010101010101; base 4: 1111111; ) 5740( base 6: 42324; base 9: 7777; ) 5840( base 3: 22000022; base 9: 8008; ) 5854( base 6: 43034; base 7: 23032; ) 6148( base 6: 44244; base 7: 23632; ) 6200( base 3: 22111122; base 9: 8448; ) 6560( base 3: 22222222; base 9: 8888; ) 6562( base 3: 100000001; base 9: 10001; ) 6643( base 2: 1100111110011; base 3: 100010001; base 9: 10101; ) 6697( base 4: 1220221; base 8: 15051; ) 6724( base 3: 100020001; base 9: 10201; ) 6761( base 4: 1221221; base 8: 15151; ) 6825( base 4: 1222221; base 8: 15251; ) 6886( base 9: 10401; base 10: 6886; ) 6889( base 4: 1223221; base 8: 15351; ) 6953( base 7: 26162; base 8: 15451; ) 7300( base 3: 101000101; base 9: 11011; ) 7373( base 4: 1303031; base 6: 54045; ) 7381( base 3: 101010101; base 9: 11111; ) 7409( base 6: 54145; base 8: 16361; ) 7447( base 2: 1110100010111; base 10: 7447; ) 7462( base 3: 101020101; base 9: 11211; ) 7517( base 4: 1311131; base 6: 54445; ) 7667( base 6: 55255; base 10: 7667; ) 7703( base 6: 55355; base 7: 31313; ) 7777( base 6: 100001; base 10: 7777; ) 7801( base 7: 31513; base 8: 17171; ) 7997( base 4: 1330331; base 10: 7997; ) 8038( base 3: 102000201; base 9: 12021; ) 8119( base 3: 102010201; base 9: 12121; ) 8194( base 4: 2000002; base 8: 20002; ) 8200( base 3: 102020201; base 7: 32623; base 9: 12221; ) 8258( base 4: 2001002; base 8: 20102; ) 8281( base 6: 102201; base 9: 12321; ) 8322( base 4: 2002002; base 8: 20202; ) 8386( base 4: 2003002; base 8: 20302; ) 8578( base 3: 102202201; base 8: 20602; ) 8778( base 8: 21112; base 10: 8778; ) 8802( base 4: 2021202; base 7: 34443; ) 9009( base 2: 10001100110001; base 10: 9009; ) 9103( base 3: 110111011; base 7: 35353; ) 9201( base 2: 10001111110001; base 7: 35553; ) 9222( base 4: 2100012; base 5: 243342; ) 9490( base 3: 111000111; base 8: 22422; ) 9958( base 4: 2123212; base 7: 41014; )