All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 Doubles on reverse (Posted on 2008-09-02)
In the problem "Mirror, mirror on the wall" it was proved that no number in the decimal system doubles on reversing its digits, and answered for bases 3, 5 and 8 (base 2 has leading zero, so itīs not valid).

Generalise the answer for positive integer bases.

 See The Solution Submitted by pcbouhid Rating: 3.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
 computer exploration -- some answers given | Comment 1 of 3

The following is not a general solution, but covers bases up to 124 for numbers 1 to 3600.

The program below tests numbers that in decimal are 1 to 3600, in bases up to 124, but stops if the point is reached where the number is represented by a single digit.

CLS
DEFDBL A-Z
digits\$ = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ---------------------------------------------------------------"
bMax = LEN(digits\$) - 1: PRINT bMax
FOR n = 1 TO 3600
b = 2
DO
n\$ = "": n2\$ = "": n2 = 0
t = n
DO
d = t MOD b
t = t \ b
dig\$ = MID\$(digits\$, d + 1, 1)
n\$ = dig\$ + n\$
n2\$ = n2\$ + dig\$
n2 = n2 * b + d
LOOP UNTIL t = 0
IF n2 = 2 * n THEN
PRINT "base";
PRINT USING "###"; b;
PRINT "; decimal ";
PRINT USING "######"; n2; n;
PRINT "; "; n2\$; " "; n\$
END IF
b = b + 1
LOOP UNTIL LEN(n\$) = 1 OR b > bMax
NEXT

The results are sorted below on base and the number. The decimal representations of the number and reverse are shown as well as the representations in the given base. For bases higher than ten, lower-case letters a through z represent 10 through 35, and capital A through Z represent 36 through 61. When a digit higher than 61 is needed, its place is taken by a hyphen. The program kept track of the actual value of that hyphen, so that spurious matches are not shown just because a hyphen was used for different digits.

`base  3; decimal     64    32; 2101 1012base  3; decimal    208   104; 21201 10212base  3; decimal    640   320; 212201 102212base  3; decimal   1936   968; 2122201 1022212base  3; decimal   5248  2624; 21012101 10121012base  3; decimal   5824  2912; 21222201 10222212`
`base  5; decimal     16     8; 31 13base  5; decimal     96    48; 341 143base  5; decimal    416   208; 3131 1313base  5; decimal    496   248; 3441 1443base  5; decimal   2016  1008; 31031 13013base  5; decimal   2496  1248; 34441 14443`
`base  6; decimal    980   490; 4312 2134base  6; decimal   6020  3010; 43512 21534`
`base  8; decimal     42    21; 52 25base  8; decimal    378   189; 572 275base  8; decimal   2730  1365; 5252 2525base  8; decimal   3066  1533; 5772 2775`
`base  9; decimal   4800  2400; 6523 3256`
`base 11; decimal     80    40; 73 37base 11; decimal    960   480; 7a3 3a7`
`base 14; decimal    130    65; 94 49base 14; decimal   1950   975; 9d4 4d9`
`base 17; decimal    192    96; b5 5bbase 17; decimal   3456  1728; bg5 5gb`
`base 20; decimal    266   133; d6 6dbase 20; decimal   5586  2793; dj6 6jd`
`base 23; decimal    352   176; f7 7fbase 26; decimal    450   225; h8 8hbase 29; decimal    560   280; j9 9jbase 32; decimal    682   341; la albase 35; decimal    816   408; nb bnbase 38; decimal    962   481; pc cpbase 41; decimal   1120   560; rd drbase 44; decimal   1290   645; te etbase 47; decimal   1472   736; vf fvbase 50; decimal   1666   833; xg gxbase 53; decimal   1872   936; zh hzbase 56; decimal   2090  1045; Bi iBbase 59; decimal   2320  1160; Dj jDbase 62; decimal   2562  1281; Fk kFbase 65; decimal   2816  1408; Hl lHbase 68; decimal   3082  1541; Jm mJbase 71; decimal   3360  1680; Ln nLbase 74; decimal   3650  1825; No oNbase 77; decimal   3952  1976; Pp pPbase 80; decimal   4266  2133; Rq qRbase 83; decimal   4592  2296; Tr rTbase 86; decimal   4930  2465; Vs sVbase 89; decimal   5280  2640; Xt tXbase 92; decimal   5642  2821; Zu uZbase 95; decimal   6016  3008; -v v-base 98; decimal   6402  3201; -w w-base101; decimal   6800  3400; -x x-`

 Posted by Charlie on 2008-09-02 17:43:46

 Search: Search body:
Forums (0)