## Friday, May 22, 2020

### [mgfxwxzr] Bases with good representations of fractions

These are the numbers less than 1000 whose reciprocals have decimal expansions which terminate or repeat with period 1 or 2.  Such decimal expansions are desirable because the eye can quickly detect low-period repetitions.

? base=10 ; print1(base , ":") ; for(q=2 , 1000 , p=q/gcd(q , base^99) ; success=0 ; for(n=1 , 2 , if(0==(base^n-1)%p || 0==(base^n)%p , success=1)) ; if(1==success , print1(" " , q)))
10: 2 3 4 5 6 8 9 10 11 12 15 16 18 20 22 24 25 30 32 33 36 40 44 45 48 50 55 60 64 66 72 75 80 88 90 96 99 100 110 120 125 128 132 144 150 160 165 176 180 192 198 200 220 225 240 250 256 264 275 288 300 320 330 352 360 375 384 396 400 440 450 480 495 500 512 528 550 576 600 625 640 660 704 720 750 768 792 800 825 880 900 960 990 1000

We repeat for a few other bases.

6: 2 3 4 5 6 7 8 9 10 12 14 15 16 18 20 21 24 27 28 30 32 35 36 40 42 45 48 54 56 60 63 64 70 72 80 81 84 90 96 105 108 112 120 126 128 135 140 144 160 162 168 180 189 192 210 216 224 240 243 252 256 270 280 288 315 320 324 336 360 378 384 405 420 432 448 480 486 504 512 540 560 567 576 630 640 648 672 720 729 756 768 810 840 864 896 945 960 972

12: 2 3 4 6 8 9 11 12 13 16 18 22 24 26 27 32 33 36 39 44 48 52 54 64 66 72 78 81 88 96 99 104 108 117 128 132 143 144 156 162 176 192 198 208 216 234 243 256 264 286 288 297 312 324 351 352 384 396 416 429 432 468 486 512 528 572 576 594 624 648 702 704 729 768 792 832 858 864 891 936 972

21: 2 3 4 5 6 7 8 9 10 11 12 14 15 18 20 21 22 24 27 28 30 33 35 36 40 42 44 45 49 54 55 56 60 63 66 70 72 77 81 84 88 90 98 99 105 108 110 120 126 132 135 140 147 154 162 165 168 180 189 196 198 210 216 220 231 243 245 252 264 270 280 294 297 308 315 324 330 343 360 378 385 392 396 405 420 440 441 462 486 490 495 504 539 540 567 588 594 616 630 648 660 686 693 729 735 756 770 792 810 840 882 891 924 945 972 980 990

30: 2 3 4 5 6 8 9 10 12 15 16 18 20 24 25 27 29 30 31 32 36 40 45 48 50 54 58 60 62 64 72 75 80 81 87 90 93 96 100 108 116 120 124 125 128 135 144 145 150 155 160 162 174 180 186 192 200 216 225 232 240 243 248 250 256 261 270 279 288 290 300 310 320 324 348 360 372 375 384 400 405 432 435 450 464 465 480 486 496 500 512 522 540 558 576 580 600 620 625 640 648 675 696 720 725 729 744 750 768 775 783 800 810 837 864 870 899 900 928 930 960 972 992 1000

60: 2 3 4 5 6 8 9 10 12 15 16 18 20 24 25 27 30 32 36 40 45 48 50 54 59 60 61 64 72 75 80 81 90 96 100 108 118 120 122 125 128 135 144 150 160 162 177 180 183 192 200 216 225 236 240 243 244 250 256 270 288 295 300 305 320 324 354 360 366 375 384 400 405 432 450 472 480 486 488 500 512 531 540 549 576 590 600 610 625 640 648 675 708 720 729 732 750 768 800 810 864 885 900 915 944 960 972 976 1000

Base 6 works on all denominators up to and including 1/12, except for 1/11.
Base 21 works on all denominators up to and including 1/15, except for 1/13.
Base 55 works on all denominators up to and including 1/16, except for 1/13.
Base 120 works on all denominators up to and including 1/18, except for 1/13.
Base 351 works on all denominators up to and including 1/16 (no internal exceptions).
Base 441 works on all denominators up to and including 1/22, except for 1/19.
Base 714 works on all denominators up to and including 1/24, except for 1/19.

? factor(714)
[ 2 1]
[ 3 1]
[ 7 1]
[17 1]

? factor(714^2-1)
[ 5 1]
[11 1]
[13 1]
[23 1]
[31 1]

Base 2001 works on all denominators up to and including 1/30, except for 1/17 and 1/19.

This code looks for bases which have no exceptions:

? for(pmax=2 , +oo , for(base=2 , +oo , fails=0 ; for(q=2 , pmax , p=q/gcd(q , base^99) ; success=0 ; for(n=1 , 2 , if(0==(base^n-1)%p || 0==(base^n)%p , success=1)) ; if(0==success , fails++)) ; if(fails<=0 , print(pmax , " " , base) ; break)))
2 2
3 2
4 2
5 4
6 4
7 6
8 6
9 6
10 6
11 21
12 21
13 351
14 351
15 351
16 351
17 441
18 441
19 7734
20 7734
21 7734
22 7734
23 52326
24 52326
25 52326
26 52326
27 52326
28 52326
29 671670

This code looks for bases which have one exception:

? for(pmax=2 , +oo , for(base=2 , +oo , fails=0 ; for(q=2 , pmax , p=q/gcd(q , base^99) ; success=0 ; for(n=1 , 2 , if(0==(base^n-1)%p || 0==(base^n)%p , success=1)) ; if(0==success , fails++)) ; if(fails<=1 , print(pmax , " " , base) ; break)))
2 2
3 2
4 2
5 2
6 2
7 4
8 4
9 6
10 6
11 6
12 6
13 21
14 21
15 21
16 55
17 120
18 120
19 441
20 441
21 441
22 441
23 714
24 714
25 10374
26 10374
27 10374
28 10374
29 52326
30 52326
31 671670