Fractions#




Rational Numbers#


Definition: rational number#

Definition

A rational number is a member of the set

\( \begin{aligned} \mathbb{Q} = \left \{ \frac{p}{q} \mid p, q \in \mathbb{Z}, q \ne 0 \right \} \end {aligned} \)

This is to say that a rational number is any number of the form \(p/q\) with \(p\) any integer and \(q\) any integer other than \(0\).


Base-\(b\) fraction#

Definition

When expressed in the base-\(b\) positional numeral system, the radix-point representation of a rational number is called a base-\(b\) fraction; is written in base-\(b\) notation; and is either finite (terminating) or infinite but periodic. (Infinite non-periodic radix point representations are not rational.)

Those which are terminating have the form

\( \begin{aligned} \frac{a}{b^n} \end {aligned} \)

where \(a\) is an integer and \(n \ge 0\).

When they are expressed as reduced fractions, they have the form

\( \begin{aligned} \frac{a}{\prod p_i^{n_i}} \end {aligned} \)

where the \(p_i\) are unique primes and each \(n_i \ge 0\)

\( \begin{aligned} 0.25 &= \frac{25}{100} = \frac{25}{10^2} = \frac{5^2}{2^2 \times 5^2} = \frac{1}{2^2} \\ 0.123456789 &= \frac{123456789}{10^9} \\ \end {aligned} \)

import math
import decimal
decimal.getcontext().prec = 100

print(f'{decimal.Decimal(1)/decimal.Decimal(2)}')
print(f'{decimal.Decimal(1)/decimal.Decimal(2** 2)}')
print(f'{decimal.Decimal(1)/decimal.Decimal(2** 3)}')
print(f'{decimal.Decimal(1)/decimal.Decimal(2** 4)}')
print(f'{decimal.Decimal(1)/decimal.Decimal(2** 5)}')
print(f'{decimal.Decimal(1)/decimal.Decimal(2** 6)}')
print(f'{decimal.Decimal(1)/decimal.Decimal(2** 7)}')
print(f'{decimal.Decimal(1)/decimal.Decimal(2** 8)}')
print(f'{decimal.Decimal(1)/decimal.Decimal(2** 9)}')
print(f'{decimal.Decimal(1)/decimal.Decimal(2**10)}')

print(f'{decimal.Decimal(1)/decimal.Decimal(5)}')
print(f'{decimal.Decimal(1)/decimal.Decimal(5**2)}')
print(f'{decimal.Decimal(1)/decimal.Decimal(5**3)}')
print(f'{decimal.Decimal(1)/decimal.Decimal(5**4)}')
print(f'{decimal.Decimal(1)/decimal.Decimal(5**5)}')
print(f'{decimal.Decimal(1)/decimal.Decimal(5**6)}')
print(f'{decimal.Decimal(1)/decimal.Decimal(5**7)}')
print(f'{decimal.Decimal(1)/decimal.Decimal(5**8)}')
print(f'{decimal.Decimal(1)/decimal.Decimal(5**9):f}')
print(f'{decimal.Decimal(1)/decimal.Decimal(5**10):f}')
0.5
0.25
0.125
0.0625
0.03125
0.015625
0.0078125
0.00390625
0.001953125
0.0009765625
0.2
0.04
0.008
0.0016
0.00032
0.000064
0.0000128
0.00000256
0.000000512
0.0000001024

Claim: there is no smallest positive rational number#

Claim

There is no smallest positive rational number.

Proof by contradiction

Suppose \(\varepsilon \gt 0\) is the smallest positive number.

\(\exists n \in \mathbb{N} \quad n \gt \frac{1}{\varepsilon} \gt 0 \quad \iff \quad 0 \lt 1 \lt n \varepsilon \quad \iff \quad 0 \lt \frac{1}{n} \lt \varepsilon\)

Thus there is a rational number \(\frac{1}{n}\) strictly smaller then \(\varepsilon\).

\(\blacksquare\)


Claim: \(\sqrt{2}\) is irrational#

Claim

\(\sqrt{2}\) is irrational.

\( \boxed{ \forall p, q \in \mathbb{Z} \quad \sqrt{2} \ne p/q } \)

Proof by contradiction

Let \(\sqrt{2} = \frac{m}{n}\) where \(m\) and \(n\) are integers and the fraction is reduced (i.e., \(m\) and \(n\) have no common divisors larger than \(1\)).

\( \begin{aligned} \sqrt{2} &= \frac{m}{n} && \text{hypothesis} \\ 2 &= \frac{m^2}{n^2} \\ 2n^2 &= m^2 \\ 2 &\mid m^2 \\ 2 \mid m^2 &\rightarrow 2 \mid m \\ 2 &\mid m && \text{modus ponens} \\ 2 \mid m^2 &\rightarrow 4 \mid m^2 \\ 4 &\mid m^2 && \text{modus ponens} \\ 4 &\mid 2n^2 \\ 2 &\mid n^2 \\ 2 \mid n^2 &\rightarrow 2 \mid n \\ 2 &\mid n && \text{modus ponens} \\ 2 \mid m &\land 2 \mid n && \text{contradiction, m and n have no common divisors larger than 1} \\ \end{aligned} \)

\(\blacksquare\)


Claim: the square root of a non-perfect square is irrational#

decimal.getcontext().prec = 200
for a in range(2, 101):
  print(f'{decimal.Decimal(a).sqrt()}')
1.4142135623730950488016887242096980785696718753769480731766797379907324784621070388503875343276415727350138462309122970249248360558507372126441214970999358314132226659275055927557999505011527820605715
1.7320508075688772935274463415058723669428052538103806280558069794519330169088000370811461867572485756756261414154067030299699450949989524788116555120943736485280932319023055820679748201010846749232650
2
2.2360679774997896964091736687312762354406183596115257242708972454105209256378048994144144083787822749695081761507737835042532677244470738635863601215334527088667781731918791658112766453226398565805358
2.4494897427831780981972840747058913919659474806566701284326925672509603774573150265398594331046402348185946012266141891248588654598377573416257839512372785528289127475276765712476301052709117702234813
2.6457513110645905905016157536392604257102591830824501803683344592010688232302836277603928864745436106150645783384974630957435298886272147844273905558801077227171507297283238922996895948650872607009781
2.8284271247461900976033774484193961571393437507538961463533594759814649569242140777007750686552831454700276924618245940498496721117014744252882429941998716628264453318550111855115999010023055641211429
3
3.1622776601683793319988935444327185337195551393252168268575048527925944386392382213442481083793002951873472841528400551485488560304538800146905195967001539033449216571792599406591501534741133394841241
3.3166247903553998491149327366706866839270885455893535970586821461164846426090438467088433991282906509070125578495274565922754397848575474797793249330447288473028739748286556825773944446120980444771931
3.4641016151377545870548926830117447338856105076207612561116139589038660338176000741622923735144971513512522828308134060599398901899979049576233110241887472970561864638046111641359496402021693498465300
3.6055512754639892931192212674704959462512965738452462127104530562271669482930104452046190820184907176735141820240635403760306782646978077051630171668927097577426905642741526332338303949623469447962732
3.7416573867739413855837487323165493017560198077787269463037454673200351563069390279768098951943795715009910887277519775455065653681642425926600420525518351174074011244748586319111000152304026279990639
3.8729833462074168851792653997823996108329217052915908265875737661134830919369790335192873768586735179163022068609496470131895404391636496156798917461212035110687547910134935812839195312288892925658464
4
4.1231056256176605498214098559740770251471992253736204343986335730949543463376215935878636508106842966845440409392141416153014208404158683630795481457469069776770232664362408630877905675723857082255214
4.2426406871192851464050661726290942357090156261308442195300392139721974353863211165511626029829247182050415386927368910747745081675522116379323644912998074942396679977825167782673998515034583461817144
4.3588989435406735522369819838596156591370039252324449368903441381595573282031580856561591558519445269056586212982742136295839927838261170121565608364174699009777529188794058900619967156631207402231024
4.4721359549995793928183473374625524708812367192230514485417944908210418512756097988288288167575645499390163523015475670085065354488941477271727202430669054177335563463837583316225532906452797131610715
4.5825756949558400065880471937280084889844565767679719026072421239068684255477708866043615594934450326776009053975857408733118991707556019635738633623447553702817228244277981919405969049143449200907589
4.6904157598234295545656301135444662805882283534117371536057018910170246327532397214821155960615431353545958966615086074816519524407829256216669587091816644475006412621612507549281883318625299999547607
4.7958315233127195415974380641626939199967070419041293464853091144482572359074640824921914464369188606174745632457368651339289039212302654888457837943340796647275696716534943439784345614167987213151199
4.8989794855663561963945681494117827839318949613133402568653851345019207549146300530797188662092804696371892024532283782497177309196755146832515679024745571056578254950553531424952602105418235404469626
5
5.0990195135927848300282241090227819895637709460995964075849708044259336320622241955883488510939320083611902582410399106614317793411215362998027726261199368133520082339240815865151806094369250287447031
5.1961524227066318805823390245176171008284157614311418841674209383557990507264001112434385602717457270268784242462201090899098352849968574364349665362831209455842796957069167462039244603032540247697950
5.2915026221291811810032315072785208514205183661649003607366689184021376464605672555207857729490872212301291566769949261914870597772544295688547811117602154454343014594566477845993791897301745214019561
5.3851648071345040312507104915403295562951201616447888376803886700166459628276586928766337816798354844187048217939457606076886214019815556269532167282089245286717225261852146812359900130524480162903887
5.4772255750516611345696978280080213395274469499798325422689444973249327712272273380085843616387062576472682594285139224407200789882646558891471252604198935050656868264028988871051985377336304477847147
5.5677643628300219221194712989185495204763933775704143039684325856035898392542362929272183961849266784232165273979702662246059605013064646282681808419453379149333606084327393411893979331802930420688912
5.6568542494923801952067548968387923142786875015077922927067189519629299138484281554015501373105662909400553849236491880996993442234029488505764859883997433256528906637100223710231998020046111282422859
5.7445626465380286598506114682189293182202644579827923676998774705659007214574046270271253655967881224195574769456508378699348226152034034016185320195623077727279780166059158065937139742960566892208393
5.8309518948453004708741528775455830765213983348859719544500067448678100619967126276652403264530353985567896220753549113518138736161708062859032260788244471816650543597702392681686483765432696564217300
5.9160797830996160425673282915616170484155012307943403228797196691428224591056530367657525271831091780886256351142545557014556938552338585094349499376739498383895803700961289381157992259578429781758257
6
6.0827625302982196889996842452020670620849700947864111864191530464863327253189102398030664279578486634309351009051311637335380630767099485320383186097849995856628707940771530658337937645881664262317752
6.1644140029689764502501923814542442252356240234445745448745720724583996502636642129667297991988999451485573039376372358875471600792658521760774197322762213297753418109603138362566974097121924856614309
6.2449979983983982058468931209397944610729599779916563084529719306096112005835145006333361122213405871078349258574629044252950568604567243495990597880972889480590074765230840349978985860648346791063790
6.3245553203367586639977870888654370674391102786504336537150097055851888772784764426884962167586005903746945683056801102970977120609077600293810391934003078066898433143585198813183003069482266789682482
6.4031242374328486864882176746218132645204201326210188855292726266681827581968760742893543022498699631708118325037971832624697443725142112330988364172050650439039921343140743747700211730776936057203656
6.4807406984078602309659674360879966577052043070583465497113543978096173778440443714003609066056102356754505420974116943354919134049066086889458189616646739513055852278226360956688226806687615217766337
6.5574385243020006523441099976360016279269663198837897698654601055856598534885756393558052909696785480205411487092432948778350774256228665603878572113758557372053351090456851332197091046894344386347945
6.6332495807107996982298654733413733678541770911787071941173642922329692852180876934176867982565813018140251156990549131845508795697150949595586498660894576946057479496573113651547888892241960889543862
6.7082039324993690892275210061938287063218550788345771728126917362315627769134146982432432251363468249085245284523213505127598031733412215907590803646003581266003345195756374974338299359679195697416073
6.7823299831252681390645563266259691051957483239232882327502195820807282639871125898626409409363300442287000181967426685942998961358601841490652156523645059927977397852813630015367571073924151444703591
6.8556546004010441249358714490848489604606434610013262754851081856785171151368169992273251485000668369387569463435050661463046586231209369361955981526052741257505749402788460391895965942489416118534618
6.9282032302755091741097853660234894677712210152415225122232279178077320676352001483245847470289943027025045656616268121198797803799958099152466220483774945941123729276092223282718992804043386996930601
7
7.0710678118654752440084436210484903928483593768847403658833986899536623923105351942519376716382078636750692311545614851246241802792536860632206074854996791570661133296375279637789997525057639103028574
7.1414284285428499979993998113672652787661711599027338332084308827658204064400218862589882135328204182344896322605085215295815466096322465946787839686916244470357893130712278304054854497502892233699591
7.2111025509279785862384425349409918925025931476904924254209061124543338965860208904092381640369814353470283640481270807520613565293956154103260343337854195154853811285483052664676607899246938895925465
7.2801098892805182710973024915270327937776696825764774383781817912841157386249051833295794090809267521926345704730578121591478607551197854097861346782052065719981334333481202942475392280650066566606151
7.3484692283495342945918522241176741758978424419700103852980777017528811323719450796195782993139207044557838036798425673745765963795132720248773518537118356584867382425830297137428903158127353106704439
7.4161984870956629487113974408007130609799043190975015987326232643438301843138502427530092131958249435060251118527371575593825139136423010154461705926617347552313804518958130491099187304014989155571111
7.4833147735478827711674974646330986035120396155574538926074909346400703126138780559536197903887591430019821774555039550910131307363284851853200841051036702348148022489497172638222000304608052559981277
7.5498344352707496972366848069461170582221947046233801382986269057107219539178111955824520741475239725844805423035157662458783507649332000555248164549891235486173086744908698071616786779551450935724945
7.6157731058639082856614110271583230053607055925465984689504842405203521573730012446422697143871516456159754405294463161782232691575521416341683715145671575570830142116864678782934713885175716318188333
7.6811457478686081757696870217313724730624510776148839280247364839355416579927098518560477279613777990163890596843161121054272109435603196185138761250222033127370837786598564116322367990051535297322558
7.7459666924148337703585307995647992216658434105831816531751475322269661838739580670385747537173470358326044137218992940263790808783272992313597834922424070221375095820269871625678390624577785851316928
7.8102496759066543941297227357591014135683051366485633001772437601907855889367270544254330522670048951809016347174073124814645423508312509409587191924342753556457573666259976822115180663887389133915306
7.8740078740118110196850344488120078636810861220208537945988425503137608468176980569261913512487468899274528896885176656037207165466281832245669587779201962338692686878093824711350350963633007054081039
7.9372539331937717715048472609177812771307775492473505411050033776032064696908508832811786594236308318451937350154923892872305896658816443532821716676403231681514521891849716768990687845952617821029342
8
8.0622577482985496523666132303037711311343963056085733879365923892638749510256882029601542667172306436374424661399459122137486521203713617318640664998639516346680732476140964607778153697072738489747875
8.1240384046359603604598835682660403485042040867253128276515755945329168028406726949991576029479368774379795115158706979971130233106785864212780932877481518908006112423387355553565737525114572222055108
8.1853527718724499699537037247339294588804868154980399630667152027236676144610979453439246716378683445347112751560062117629486101122041499597215679276595504061556730049674275869872067932507202423696525
8.2462112512353210996428197119481540502943984507472408687972671461899086926752431871757273016213685933690880818784282832306028416808317367261590962914938139553540465328724817261755811351447714164510428
8.3066238629180748525842627449074920102322142489556557794321883690375850334231515738673985082323570502650140398579058715564968053169772933677466362900537190348219845363540128702276531157493212912316442
8.3666002653407554797817202578518748939281536929867219981119154308041877259431700983081471196495153616539829886670005366818085500267591292170185983575372535614070629200287506930116586139040099402004607
8.4261497731763586306341399062027360316080024015607500136678111293272255027552030554856935372989696590710268270756597231945252158480986050984086757096672032616737347462276528839657396417949308142503335
8.4852813742385702928101323452581884714180312522616884390600784279443948707726422331023252059658494364100830773854737821495490163351044232758647289825996149884793359955650335565347997030069166923634288
8.5440037453175311678716483262397064345944553295332822419086512537716488193272983810809720301070094296006326527052708678496692766775147416252724364926530251797139849089416612292723769440572485560534202
8.6023252670426267717294735350497136320275355572907356195080456412374269346630170127833308906989620643961833585872424486369871987918628114443286285813460863582642520203052917276153146201033762720557549
8.6602540378443864676372317075293618347140262690519031402790348972596650845440001854057309337862428783781307070770335151498497254749947623940582775604718682426404661595115279103398741005054233746163251
8.7177978870813471044739639677192313182740078504648898737806882763191146564063161713123183117038890538113172425965484272591679855676522340243131216728349398019555058377588117801239934313262414804462048
8.7749643873921220604063883074163095608758768275545035909276956297827646462193062816756931570687057559376509872409905802416686553752517477572146708851227131510230292241002964068906473742342555235360607
8.8317608663278468547640427269592539641746394809314178262102029725571399382354428403704355394147715177336298254657760131157341254118470733273490885404798363352391906275767076768586794292867784251194751
8.8881944173155888500914416754087278170764506037295262983547201163761005996285995960235929527136305531572553393912710668994040926720086833684910226619300416917521751833103766854153073873463613059628836
8.9442719099991587856366946749251049417624734384461028970835889816420837025512195976576576335151290998780327046030951340170130708977882954543454404861338108354671126927675166632451065812905594263221430
9
9.0553851381374166265738081669840664130521244640969402765817412300186579807660592333849606785909909264457605150586778478304554915747504894737052510207241109504079084976278564826004142401720838787055588
9.1104335791442988819456261046886691900991391682649558524969384650660211942834056655853414609291772467392469263375806996277188833018479713212634239934084257902132096108839857446223581341982419852888703
9.1651513899116800131760943874560169779689131535359438052144842478137368510955417732087231189868900653552018107951714817466237983415112039271477267246895107405634456488555963838811938098286898401815179
9.2195444572928873100022742817627931572468050487224640080077522054426710268018754607678940907932805649403398088788716841521246633465171722339398057111487771732015843132779951574309724454413579467764258
9.2736184954957037525164160739901746262634689120762982133738265983282368364638430232320458573584743842452165762824641162613268599562026590133654641372300489142747900674806838018601484629392338537427396
9.3273790530888150455544755423205569832762406941916546710561972984467845488072496784142205629118820160044848274987435977588581638862854968878008273157620663117495091428678637715577187985660062812106753
9.3808315196468591091312602270889325611764567068234743072114037820340492655064794429642311921230862707091917933230172149633039048815658512433339174183633288950012825243225015098563766637250599999095213
9.4339811320566038113206603776226407169836226334151213206629814489800229095851180585410269868903841045350129742817498749829425249898532185221933827433201100290351854895379614777469719207287855232212582
9.4868329805051379959966806332981556011586654179756504805725145583777833159177146640327443251379008855620418524585201654456465680913616400440715587901004617100347649715377798219774504604223400184523723
9.5393920141694564915262158602322654025462342525054575390815185291036255230565072182778217644912206982248047270565568810629641875366075664205587217485112358253619515898318033030763627327853141830993962
9.5916630466254390831948761283253878399934140838082586929706182288965144718149281649843828928738377212349491264914737302678578078424605309776915675886681593294551393433069886879568691228335974426302398
9.6436507609929549957600310474326631839069036930632524073001768877312864186686497229000547092936085910813735834079459888525078156923158960159673355918346889559335228277696014305185023001631661086163012
9.6953597148326580281488811508453133936521509879546795905397174862330398675733007284832586784769174965761217583961461720749739508186659384572218446059393320499014838286486802838438228573681815397722798
9.7467943448089639068384131998996002992525839003374910319917500057200817724602493568487120960380655275565398814077562431392566503698274552459716672732910651642211674708692097257369453249429567132222776
9.7979589711327123927891362988235655678637899226266805137307702690038415098292601061594377324185609392743784049064567564994354618393510293665031358049491142113156509901107062849905204210836470808939252
9.8488578017961047217462114149176244816961362874427641717231545298364405837076786300932007841154257624381011988717491997180751037381469502849289227809728869989613900774752564814979436103320980003879403
9.8994949366116653416118210694678865499877031276386365122367581659351273492347492719527127402934910091450969236163860791744738523909551604885088504796995508198925586614925391492905996535080694744240003
9.9498743710661995473447982100120600517812656367680607911760464383494539278271315401265301973848719527210376735485823697768263193545726424393379747991341865419086219244859670477321833338362941334315793
10



Repunits#

Definition

The repunits are the decimal numbers \(R_n\) with \(n\) ones and no other digits.


Here are the first few repunits along with their unique prime factorizations.

\( \begin{aligned} R_1 &= 1 && \\ R_2 &= 11 &&= \phantom{111} \textcolor{#0096FF}{11} \\ R_3 &= 111 &&= \phantom{1111} 3 \times \phantom{1111} \textcolor{#0096FF}{37} \\ R_4 &= 1111 &&= \phantom{111} 11 \times \phantom{111} \textcolor{#0096FF}{101} \\ R_5 &= 11111 &&= \phantom{111} \textcolor{#0096FF}{41} \times \phantom{111} \textcolor{#0096FF}{271} \\ R_6 &= 111111 &&= \phantom{111} 11 \times \phantom{11111} 3 \times \phantom{11} \textcolor{#0096FF}{7} \times \phantom{1111} \textcolor{#0096FF}{13} \times 37 \\ R_7 &= 1111111 &&= \phantom{11} \textcolor{#0096FF}{239} \times \phantom{11} \textcolor{#0096FF}{4649} \\ R_8 &= 11111111 &&= \phantom{111} 11 \times \phantom{1111} \textcolor{#0096FF}{73} \times 101 \times \phantom{111} \textcolor{#0096FF}{137} \\ R_9 &= 111111111 &&= \phantom{1111} 3 \times \phantom{11111} 3 \times \phantom{1} 37 \times \textcolor{#0096FF}{333667} \\ R_{10} &= 1111111111 &&= \phantom{111} 11 \times \phantom{1111} 41 \times 271 \times \phantom{11} \textcolor{#0096FF}{9091} \\ R_{11} &= 11111111111 &&= \textcolor{#0096FF}{21649} \times \textcolor{#0096FF}{513239} \\ \vdots \\ \end {aligned} \)

import decimal
decimal.getcontext().prec = 100
m = 1
n = 2**7
decimal.Decimal(m)/decimal.Decimal(n)
Decimal('0.0078125')

Claim: \(R_n = (10^n - 1) / 9\)#

Claim

The decimal number \(R_n\) with \(n\) ones and no other digits is just

\((10^n - 1) / 9\)

Proof

Let \(R_n\) be a decimal number with \(n\) ones and no other digits.

\( \begin{aligned} R_n \phantom{+1} &= (10^n - 1) / 9 \\ 9 R_n \phantom{+1} &= \phantom{(} 10^n - 1 \\ 9 R_n + 1 &= \phantom{(} 10^n \\ \end {aligned} \)

Then \(9R_n\) is a decimal number with \(n\) nines and no other digits. One more than that is the decimal number that consists of a \(1\) followed by \(n\) zeros, which is just \(10^n\).

\(\blacksquare\)


Claim: \(R_m \mid R_n \iff m \mid n\)#

Claim

\(R_m \mid R_n \iff m \mid n\)

Proof

First Direction

We must show that if \(R_m \mid R_n\) then \(m \mid n\).

Suppose \(R_m \mid R_n\). Then there is an integer \(k\) such that

\( \begin{aligned} R_n = R_m k \quad \iff \quad \frac{10^n - 1}{9} = \frac{10^m - 1}{9} k \quad \iff \quad 10^n - 1 = (10^m - 1) k \end {aligned} \)

We employ difference of powers.

\( \begin{aligned} 10^n - 1^n = (10 - 1)(10^{n-1} + 10^{n-2} + \dotsb + 10 + 1) = (10^m - 1) k \end {aligned} \)

Second Direction

We must show that if \(m \mid n\) then \(R_m \mid R_n\).

\(\blacksquare\)

Claim: \(R_2 \mid R_{2n}\)#

Claim

\(11\) divides every repunit with an even number of ones.

Proof

\(\blacksquare\)

Claim: \(R_3 \mid R_{3n}\)#

Claim

\(111\) (and \(3\) and \(37\)) divides \(R_{3n}\) for every \(n\).

Proof

\(\blacksquare\)

Claim: \(\text{Prime}(R_n) \implies \text{Prime}(n)\)#

Claim

\(R_n\) cannot be prime unless \(n\) is prime.


In other words, \(R_6\) and \(R_9\) cannot be prime but \(R_2, R_3, R_5, R_7,\) and \(R_{11}\) might be prime.

\( \begin{aligned} R_2 &= 11 &&= \phantom{111} 11 \\ R_3 &= 111 &&= \phantom{1111} 3 \times \phantom{1111} 37 \\ R_5 &= 11111 &&= \phantom{111} 41 \times \phantom{111} 271 \\ R_7 &= 1111111 &&= \phantom{11} 239 \times \phantom{11} 4649 \\ R_{11} &= 11111111111 &&= 21649 \times 513239 \\ \vdots \\ \end {aligned} \)

It turns out that the first few prime repunits after \(R_2\) are \(R_{19}, R_{23}, R_{317},\) and \(R_{1031}\).


Proof

\(\blacksquare\)




Repeating Decimal Fractions#


Reciprocal of a prime#

Claim

When \(p\) is a prime number other than \(2\) or \(5\) the length of the period for the decimal fraction for \(1/p\) is the smallest positive integer \(n\) for which \(p\) divides \(10^n - 1\).

\( \begin{aligned} 3 & \mid (10^1 - 1) && \quad \ell \left( 3 \right) &= \phantom{1} 1 && \quad \frac{1}{ 3} &= 0.\bar{3} \\ 7 & \mid (10^6 - 1) && \quad \ell \left( 7 \right) &= \phantom{1} 6 && \quad \frac{1}{ 7} &= 0.\overline{142857} \\ 11 & \mid (10^2 - 1) && \quad \ell \left( 11 \right) &= \phantom{1} 2 && \quad \frac{1}{ 11} &= 0.\overline{09} \\ 13 & \mid (10^6 - 1) && \quad \ell \left( 13 \right) &= \phantom{1} 6 && \quad \frac{1}{ 13} &= 0.\overline{076923} \\ 17 & \mid (10^{16} - 1) && \quad \ell \left( 17 \right) &= 16 && \quad \frac{1}{ 17} &= 0.\overline{0588235294117647} \\ 19 & \mid (10^{18} - 1) && \quad \ell \left( 19 \right) &= 18 && \quad \frac{1}{ 19} &= 0.\overline{052631578947368421} \\ 23 & \mid (10^{22} - 1) && \quad \ell \left( 23 \right) &= 22 && \quad \frac{1}{ 23} &= 0.\overline{0434782608695652173913} \\ 29 & \mid (10^{28} - 1) && \quad \ell \left( 29 \right) &= 28 && \quad \frac{1}{ 29} &= 0.\overline{0344827586206896551724137931} \\ 31 & \mid (10^{15} - 1) && \quad \ell \left( 31 \right) &= 15 && \quad \frac{1}{ 31} &= 0.\overline{032258064516129} \\ 37 & \mid (10^3 - 1) && \quad \ell \left( 37 \right) &= \phantom{1} 3 && \quad \frac{1}{ 37} &= 0.\overline{027} \\ 41 & \mid (10^5 - 1) && \quad \ell \left( 41 \right) &= \phantom{1} 5 && \quad \frac{1}{ 41} &= 0.\overline{02439} \\ \vdots \\ 73 & \mid (10^8 - 1) && \quad \ell \left( 73 \right) &= \phantom{1} 8 && \quad \frac{1}{ 73} &= 0.\overline{01369863} \\ \vdots \\ 101 & \mid (10^4 - 1) && \quad \ell \left( 101 \right) &= \phantom{1} 4 && \quad \frac{1}{ 101} &= 0.\overline{0099} \\ \vdots \\ 137 & \mid (10^8 - 1) && \quad \ell \left( 137 \right) &= \phantom{1} 8 && \quad \frac{1}{ 137} &= 0.\overline{00729927} \\ \vdots \\ 239 & \mid (10^7 - 1) && \quad \ell \left( 239 \right) &= \phantom{1} 7 && \quad \frac{1}{ 239} &= 0.\overline{0041841} \\ \vdots \\ 271 & \mid (10^5 - 1) && \quad \ell \left( 271 \right) &= \phantom{1} 5 && \quad \frac{1}{ 271} &= 0.\overline{00369} \\ \vdots \\ 4649 & \mid (10^7 - 1) && \quad \ell \left( 4649 \right) &= \phantom{1} 7 && \quad \frac{1}{4649} &= 0.\overline{0002151} \\ \vdots \\ \end {aligned} \)


Primitive prime factors of \(10^n - 1\)#

Definition

The primitive prime factors of \(10^n - 1\) are the primes that divide \(10^n - 1\) but not \(10^m - 1\) for any \(0 \lt m \lt n\). These are exactly the primes \(p\) for which the length of the period of the decimal fraction for \(1/p\) is \(n\).

\( \begin{aligned} 10^n - 1 &&& \text{primitive prime factors} \\ \hline 3^2 R_1 &= 3^2 \times 1 && 3 \\ 3^2 R_2 &= 3^2 \times 11 && 11 \\ 3^2 R_3 &= 3^2 \times 111 && 37 \\ 3^2 R_4 &= 3^2 \times 1111 && 101 \\ 3^2 R_5 &= 3^2 \times 11111 && 41, 271 \\ 3^2 R_6 &= 3^2 \times 111111 && 7, 13 \\ 3^2 R_7 &= 3^2 \times 1111111 && 239, 4649 \\ 3^2 R_8 &= 3^2 \times 11111111 && 73, 137 \\ 3^2 R_9 &= 3^2 \times 111111111 && 333667 \\ 3^2 R_{10} &= 3^2 \times 1111111111 && 9091 \\ 3^2 R_{11} &= 3^2 \times 11111111111 && 21649, 513239 \\ \vdots \\ \end {aligned} \)

import decimal
decimal.getcontext().prec = 250
m = 1
n = 3*7*11
decimal.Decimal(m)/decimal.Decimal(n)
Decimal('0.004329004329004329004329004329004329004329004329004329004329004329004329004329004329004329004329004329004329004329004329004329004329004329004329004329004329004329004329004329004329004329004329004329004329004329004329004329004329004329004329004329004329')

General repeating decimal fractions#

In 1801, Gauss determined the period length of the decimal fraction for every rational number \(a/b\) in terms of the factors of numbers \(10^n - 1\).

Let \(p\) be a prime number other than \(2\) or \(5\) and let \(m\) be a positive integer.

1

If \(p\) does not divide the integer \(r\) then the length of the period of the decimal fraction \(r/p^m\) is the smallest positive integer \(e\) for which \(p^m\) divides \(10^e - 1\).

This means that \(e\) is a divisor of \(p^{m-1} (p - 1)\).

We will see that the following holds after studying congruences, Euler’s totient, and primitive roots.

\( p^m \mid (10^e - 1) \quad \iff \quad 10^e \equiv 1 \mod p^m \)

\( (e = \text{ord}_{p^m}(10)) \mid (\phi(p^m) = p^{m-1}(p-1)) \)

Call this period length \(\ell(p^m)\).

2

If \(M = p_1^{m_1} p_2^{m_2} \dotsb p_k^{m_k}\) where the \(p_i\) are distinct primes not equal to \(2\) or \(5\) then the length of the period of the decimal fraction for \(r/M\) is the least common multiple \(\ell(M)\) of the numbers \(\ell(p_1^{m_1}), \ell(p_2^{m_2}), \dotsc, \ell(p_k^{m_k})\).

In all these cases the period begins with the first digit after the decimal point.

3

In the case where \(N = 2^a 5^b M\) with \(M\) not divisible by \(2\) or \(5\) the decimal fraction for \(r/N\) becomes periodic after the first \(c\) digits following the decimal point, where \(c = \max(a, b)\), and the length of the period is \(\ell(M)\).

\( \begin{aligned} 3 & \mid (10^1 - 1) && \quad \ell \left( 3 \right) &= \phantom{1} 1 && \quad \frac{1}{3} &= 0.\overline{3} \\ & && & && \quad \frac{2}{3} &= 0.\overline{6} \\ 3^2 & \mid (10^1 - 1) && \quad \ell \left( 3^2 \right) &= \phantom{1} 1 && \quad \frac{1}{3^2} &= 0.\overline{1} \\ & && & && \quad \frac{2}{3^2} &= 0.\overline{2} \\ & && & && \quad \frac{4}{3^2} &= 0.\overline{4} \\ & && & && \quad \frac{5}{3^2} &= 0.\overline{5} \\ & && & && \quad \frac{7}{3^2} &= 0.\overline{7} \\ & && & && \quad \frac{8}{3^2} &= 0.\overline{8} \\ 3^3 & \mid (10^3 - 1) && \quad \ell \left( 3^3 \right) &= \phantom{1} 3 && \quad \frac{1}{3^3} &= 0.\overline{037} \\ & && & && \quad \frac{2}{3^3} &= 0.\overline{074} \\ & && & && \quad \frac{4}{3^3} &= 0.\overline{148} \\ & && & && \quad \frac{5}{3^3} &= 0.\overline{185} \\ & && & && \quad \frac{7}{3^3} &= 0.\overline{259} \\ & && & && \quad \frac{8}{3^3} &= 0.\overline{296} \\ &&&&&&& \vdots \\ \end {aligned} \)

\( \begin{aligned} 11 & \mid (10^2 - 1) && \quad \ell \left( 11 \right) &= \phantom{1} 2 && \quad \frac{1}{11} &= 0.\overline{09} \\ & && & && \quad \frac{2}{11} &= 0.\overline{18} \\ &&&&&&& \vdots \\ 11^2 & \mid (10^{22} - 1) && \quad \ell \left( 11^2 \right) &= \phantom{1} 22 && \quad \frac{1}{11^2} &= 0.\overline{0082644628099173553719} \\ & && & && \quad \frac{2}{11^2} &= 0.\overline{0165289256198347107438} \\ &&&&&&& \vdots \\ 11^3 & \mid (10^{242} - 1) && \quad \ell \left( 11^3 \right) &= \phantom{1} 242 && \quad \frac{1}{11^3} &= 0.\overline{00075131480090157776108189331329827197595792637114951164537941397445529676934635612321562734785875281743050338091660405709992486851990984222389181066867017280240420736288504883546205860255447032306536438767843726521412471825694966190833959429} \\ & && & && \quad \frac{2}{11^3} &= 0.\overline{00150262960180315552216378662659654395191585274229902329075882794891059353869271224643125469571750563486100676183320811419984973703981968444778362133734034560480841472577009767092411720510894064613072877535687453042824943651389932381667918858} \\ &&&&&&& \vdots \\ \end {aligned} \)

\( \begin{aligned} \frac{7}{740} = 7 \times \frac{1}{2^2 \times 5^1 \times 37} \end {aligned} \)

\(c = \max(2, 1) = 2\)

\( \begin{aligned} 37 & \mid (10^3 - 1) && \quad \ell \left( 37 \right) &= \phantom{1} 3 && \quad \frac{1}{37} &= 0.\overline{027} \\ & && & && \quad \frac{7}{37} &= 0.\overline{189} \\ & && & && \quad \frac{1}{2^2 5} &= 0.05 \\ & && & && \quad \frac{7}{740} &= 0.00\overline{945} \\ &&&&&&& \vdots \\ \end {aligned} \)

\( \begin{aligned} \frac{163}{407} = \frac{163}{11 \times 37} \end {aligned} \)

\(\ell(11) = 2, \ell(37) = 3, \text{lcm}[2, 3] = 6\)

\( \begin{aligned} \frac{1 }{407} &= 0.\overline{002457} \\ \vdots \\ \frac{163}{407} &= 0.\overline{400491} \\ \vdots \\ \end {aligned} \)

import decimal
decimal.getcontext().prec = 250
m = 123456789091111122
n = 73*11*2**10
decimal.Decimal(m)/decimal.Decimal(n)
Decimal('150141059273.7088481670298879202988792029887920298879202988792029887920298879202988792029887920298879202988792029887920298879202988792029887920298879202988792029887920298879202988792029887920298879202988792029887920298879202988792029887920298879202989')
print(f'{decimal.Decimal(1)/decimal.Decimal( 3)}')
print(f'{decimal.Decimal(1)/decimal.Decimal( 6)}')
print(f'{decimal.Decimal(1)/decimal.Decimal( 7)}')
print(f'{decimal.Decimal(1)/decimal.Decimal( 9)}')
print(f'{decimal.Decimal(1)/decimal.Decimal(11)}')
print(f'{decimal.Decimal(1)/decimal.Decimal(12)}')
print(f'{decimal.Decimal(1)/decimal.Decimal(13)}')
print(f'{decimal.Decimal(1)/decimal.Decimal(14)}')
print(f'{decimal.Decimal(1)/decimal.Decimal(15)}')
print(f'{decimal.Decimal(1)/decimal.Decimal(17)}')
print(f'{decimal.Decimal(1)/decimal.Decimal(18)}')
print(f'{decimal.Decimal(1)/decimal.Decimal(19)}')
0.3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333
0.1666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666667
0.1428571428571428571428571428571428571428571428571428571428571428571428571428571428571428571428571428571428571428571428571428571428571428571428571428571428571428571428571428571428571428571428571428571428571428571428571428571428571428571428571428571429
0.1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
0.09090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909090909091
0.08333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333
0.07692307692307692307692307692307692307692307692307692307692307692307692307692307692307692307692307692307692307692307692307692307692307692307692307692307692307692307692307692307692307692307692307692307692307692307692307692307692307692307692307692307692
0.07142857142857142857142857142857142857142857142857142857142857142857142857142857142857142857142857142857142857142857142857142857142857142857142857142857142857142857142857142857142857142857142857142857142857142857142857142857142857142857142857142857143
0.06666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666667
0.05882352941176470588235294117647058823529411764705882352941176470588235294117647058823529411764705882352941176470588235294117647058823529411764705882352941176470588235294117647058823529411764705882352941176470588235294117647058823529411764705882352941
0.05555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555556
0.05263157894736842105263157894736842105263157894736842105263157894736842105263157894736842105263157894736842105263157894736842105263157894736842105263157894736842105263157894736842105263157894736842105263157894736842105263157894736842105263157894736842



Repeating base-\(b\) fractions#


Base \(2\)#

\( \boxed{ \begin{aligned} \frac{1}{2} &= 0.1_2 \\ \frac{1}{3} &= 0.\overline{01}_2 \\ \frac{1}{4} &= 0.01_2 \\ \frac{1}{5} &= 0.\overline{0011}_2 \\ \frac{1}{6} &= 0.0\overline{01}_2 \\ \frac{1}{7} &= 0.\overline{001}_2 \\ \frac{1}{8} &= 0.001_2 \\ \frac{1}{9} &= 0.\overline{000111}_2 \\ \frac{1}{10} &= 0.0\overline{0011}_2 \\ \end {aligned} } \)

\(\boxed{\frac{1}{2} = 0.1_2}\)

\(N = 2\) only consists of prime factors of the base and so the binary fraction terminates.

\( \begin{aligned} 1 \times b &= 2 &&= \textcolor{#0096FF}{1} \times 2 + 0 \\ \end {aligned} \)

\( \begin{aligned} 0.1_2 = 1 \times 2^{-1} = \frac{1}{2} \end {aligned} \)

\(\blacksquare\)

\(\boxed{\frac{1}{3} = 0.\overline{01}_2}\)

\( \begin{aligned} 1 \times b &= 2 &&= \textcolor{#0096FF}{0} \times 3 + 2 \\ 2 \times b &= 4 &&= \textcolor{#0096FF}{1} \times 3 + 1 \\ \end {aligned} \)

\( \begin{aligned} 0.\overline{01}_2 &= 0 \times 2^{-1} + 1 \times 2^{-2} + 0 \times 2^{-3} + 1 \times 2^{-4} + 0 \times 2^{-5} + 1 \times 2^{-6} + 0 \times 2^{-7} + 1 \times 2^{-8} + \dotsb \\ &= 2^{-2} + 2^{-4} + 2^{-6} + 2^{-8} + \dotsb \\ &= 2^{-2} + (2^{-2})(2^{-2}) + (2^{-2})(2^{-2})^2 + (2^{-2})(2^{-2})^3 + \dotsb \\ &= 2^{-2} \times (1 + (2^{-2}) + (2^{-2})^2 + (2^{-2})^3 + \dotsb) \\ &= 2^{-2} \times \frac{1}{1 - 2^{-2}} \\ &= \frac{1}{4} \times \frac{4}{3} \\ &= \frac{1}{3} \\ \end {aligned} \)

\(\blacksquare\)

\(\boxed{\frac{1}{4} = 0.01_2}\)

\(N = 4 = 2^2\) only consists of prime factors of the base and so the binary fraction terminates.

\( \begin{aligned} 1 \times b &= 2 &&= \textcolor{#0096FF}{0} \times 4 + 2 \\ 2 \times b &= 4 &&= \textcolor{#0096FF}{1} \times 4 + 0 \\ \end {aligned} \)

\( \begin{aligned} 0.01_2 = 1 \times 2^{-2} = \frac{1}{4} \end {aligned} \)

\(\blacksquare\)

\(\boxed{\frac{1}{5} = 0.\overline{0011}_2}\)

\(N = 5\) is prime but is not a factor of the base. Therefore, the period is the smallest \(e\) such that \(N \mid (2^e - 1)\)

\( \begin{aligned} 1 \times b &= 2 &&= \textcolor{#0096FF}{0} \times 5 + 2 \\ 2 \times b &= 4 &&= \textcolor{#0096FF}{0} \times 5 + 4 \\ 4 \times b &= 8 &&= \textcolor{#0096FF}{1} \times 5 + 3 \\ 3 \times b &= 6 &&= \textcolor{#0096FF}{1} \times 5 + 1 \\ \end {aligned} \)

\( \begin{aligned} 0.\overline{0011}_2 &= 0 \times 2^{-1} + 0 \times 2^{-2} + 1 \times 2^{-3} + 1 \times 2^{-4} + 0 \times 2^{-5} + 0 \times 2^{-6} + 1 \times 2^{-7} + 1 \times 2^{-8} + \dotsb \\ &= (2^{-3} + 2^{-4}) + (2^{-7} + 2^{-8}) + (2^{-11} + 2^{-12}) + \dotsb \\ &= (2^{-3} + 2^{-4}) + (2^{-3} + 2^{-4})(2^{-4}) + (2^{-3} + 2^{-4})(2^{-4})^2 + \dotsb \\ &= (2^{-3} + 2^{-4}) \times (1 + (2^{-4}) + (2^{-4})^2 + \dotsb) \\ &= (2^{-3} + 2^{-4}) \times \frac{1}{1 - \frac{1}{16}} \\ &= \left( \frac{1}{8} + \frac{1}{16} \right) \times \frac{16}{15} \\ &= \frac{3}{16} \times \frac{16}{15} \\ &= \frac{1}{5} \\ \end {aligned} \)

\(\blacksquare\)

\(\boxed{\frac{1}{6} = 0.0\overline{01}_2}\)

\(N = 6 = 2^1 \times 3\) and \(\ell(3) = 2\). Therefore, the period is \(2\) and begins \(1\) digit after the radix point.

\( \begin{aligned} 1 \times b &= 2 &&= \textcolor{#0096FF}{0} \times N + 2 \\ 2 \times b &= 4 &&= \textcolor{#0096FF}{0} \times N + 4 \\ 4 \times b &= 8 &&= \textcolor{#0096FF}{1} \times N + 2 \\ \end {aligned} \)

\( \begin{aligned} 0.0\overline{01}_2 &= 0 \times 2^{-1} + 0 \times 2^{-2} + 1 \times 2^{-3} + 0 \times 2^{-4} + 1 \times 2^{-5} + 0 \times 2^{-6} + 1 \times 2^{-7} + 0 \times 2^{-8} + 1 \times 2^{-9} + \dotsb \\ &= 2^{-3} + 2^{-5} + 2^{-7} + 2^{-9} + \dotsb \\ &= 2^{-3} + (2^{-3})(2^{-2}) + (2^{-3})(2^{-2})^2 + (2^{-3})(2^{-2})^3 + \dotsb \\ &= 2^{-3} \times (1 + (2^{-2}) + (2^{-2})^2 + (2^{-2})^3 + \dotsb) \\ &= 2^{-3} \times \frac{1}{1 - \frac{1}{4}} \\ &= \frac{1}{8} \times \frac{4}{3} \\ &= \frac{1}{6} \\ \end {aligned} \)

\(\blacksquare\)

\(\boxed{\frac{1}{7} = 0.\overline{001}_2}\)

\(N = 7\) is prime but is not a factor of the base. Therefore, the period is the smallest \(e\) such that \(N \mid (2^e - 1)\).

\( \begin{aligned} 1 \times b &= 2 &&= \textcolor{#0096FF}{0} \times N + 2 \\ 2 \times b &= 4 &&= \textcolor{#0096FF}{0} \times N + 4 \\ 4 \times b &= 8 &&= \textcolor{#0096FF}{1} \times N + 1 \\ \end {aligned} \)

\( \begin{aligned} 0.\overline{001}_2 &= 0 \times 2^{-1} + 0 \times 2^{-2} + 1 \times 2^{-3} + 0 \times 2^{-4} + 0 \times 2^{-5} + 1 \times 2^{-6} + 0 \times 2^{-7} + 0 \times 2^{-8} + 1 \times 2^{-9} + \dotsb \\ &= 2^{-3} + 2^{-6} + 2^{-9} + \dotsb \\ &= 2^{-3} + (2^{-3})(2^{-3}) + (2^{-3})(2^{-3})^2 + \dotsb \\ &= 2^{-3} \times (1 + (2^{-3}) + (2^{-3})^2 + \dotsb) \\ &= 2^{-3} \times \frac{1}{1 - \frac{1}{8}} \\ &= \frac{1}{8} \times \frac{8}{7} \\ &= \frac{1}{7} \\ \end {aligned} \)

\(\blacksquare\)

\(\boxed{\frac{1}{8} = 0.001_2}\)

\(N = 8 = 2^3\) only consists of prime factors of the base and so the binary fraction terminates.

\( \begin{aligned} 1 \times b &= 2 &&= \textcolor{#0096FF}{0} \times N + 2 \\ 2 \times b &= 4 &&= \textcolor{#0096FF}{0} \times N + 4 \\ 4 \times b &= 8 &&= \textcolor{#0096FF}{1} \times N + 0 \\ \end {aligned} \)

\( \begin{aligned} 0.001_2 = 1 \times 2^{-3} = \frac{1}{8} \end {aligned} \)

\(\blacksquare\)

\(\boxed{\frac{1}{9} = 0.\overline{000111}_2}\)

\(N = 9 = 3^2\). Therefore, the period is the smallest \(e\) such that \(N \mid (2^e - 1)\)

\( \begin{aligned} 1 \times b &= 2 &&= \textcolor{#0096FF}{0} \times N + 2 \\ 2 \times b &= 4 &&= \textcolor{#0096FF}{0} \times N + 4 \\ 4 \times b &= 8 &&= \textcolor{#0096FF}{0} \times N + 8 \\ 8 \times b &= 16 &&= \textcolor{#0096FF}{1} \times N + 7 \\ 7 \times b &= 14 &&= \textcolor{#0096FF}{1} \times N + 5 \\ 5 \times b &= 10 &&= \textcolor{#0096FF}{1} \times N + 1 \\ \end {aligned} \)

\( \begin{aligned} 0.\overline{000111}_2 &= 0 \times 2^{-1} + 0 \times 2^{-2} + 0 \times 2^{-3} + 1 \times 2^{-4} + 1 \times 2^{-5} + 1 \times 2^{-6} + 0 \times 2^{-7} + 0 \times 2^{-8} + 0 \times 2^{-9} + \dotsb \\ &= (2^{-4} + 2^{-5} + 2^{-6}) + (2^{-10} + 2^{-11} + 2^{-12}) + (2^{-16} + 2^{-17} + 2^{-18}) + \dotsb \\ &= (2^{-4} + 2^{-5} + 2^{-6}) + (2^{-4} + 2^{-5} + 2^{-6})(2^{-6}) + (2^{-4} + 2^{-5} + 2^{-6})(2^{-6})^2 + \dotsb \\ &= (2^{-4} + 2^{-5} + 2^{-6}) \times (1 + (2^{-6}) + (2^{-6})^2 + \dotsb) \\ &= (2^{-4} + 2^{-5} + 2^{-6}) \times \frac{1}{1 - \frac{1}{64}} \\ &= \left( \frac{1}{16} + \frac{1}{32} + \frac{1}{64} \right) \times \frac{64}{63} \\ &= \frac{7}{64} \times \frac{64}{63} \\ &= \frac{1}{9} \\ \end {aligned} \)

\(\blacksquare\)

\(\boxed{\frac{1}{10} = 0.0\overline{0011}_2}\)

\(N = 10 = 2^1 \times 5\) and \(\ell(5) = 4\). Therefore, the period is \(4\) and begins \(1\) digit after the radix point.

\( \begin{aligned} 1 \times b &= 2 &&= \textcolor{#0096FF}{0} \times N + 2 \\ 2 \times b &= 4 &&= \textcolor{#0096FF}{0} \times N + 4 \\ 4 \times b &= 8 &&= \textcolor{#0096FF}{0} \times N + 8 \\ 8 \times b &= 16 &&= \textcolor{#0096FF}{1} \times N + 6 \\ 6 \times b &= 12 &&= \textcolor{#0096FF}{1} \times N + 2 \\ \end {aligned} \)

\( \begin{aligned} 0.0\overline{0011}_2 &= 0 \times 2^{-1} + 0 \times 2^{-2} + 0 \times 2^{-3} + 1 \times 2^{-4} + 1 \times 2^{-5} + 0 \times 2^{-6} + 0 \times 2^{-7} + 1 \times 2^{-8} + 1 \times 2^{-9} + \dotsb \\ &= (2^{-4} + 2^{-5}) + (2^{-8} + 2^{-9}) + (2^{-12} + 2^{-13}) + \dotsb \\ &= (2^{-4} + 2^{-5}) + (2^{-4} + 2^{-5})(2^{-4}) + (2^{-4} + 2^{-5})(2^{-4})^2 + \dotsb \\ &= (2^{-4} + 2^{-5}) \times (1 + (2^{-4}) + (2^{-4})^2 + \dotsb) \\ &= (2^{-4} + 2^{-5}) \times \frac{1}{1 - \frac{1}{16}} \\ &= \left( \frac{1}{16} + \frac{1}{32} \right) \times \frac{16}{15} \\ &= \frac{3}{32} \times \frac{16}{15} \\ &= \frac{1}{10} \\ \end {aligned} \)

\(\blacksquare\)


Base \(3\)#

\( \boxed{ \begin{aligned} \frac{1}{2} &= 0.\overline{1}_3 &&& \ell(2) &= 1 \\ \frac{1}{3} &= 0.1_3 &&& \\ \frac{1}{4} &= 0.\overline{02}_3 &&& \ell(4) &= 2 \\ \frac{1}{5} &= 0.\overline{0121}_3 &&& \ell(5) &= 4 \\ \frac{1}{6} &= 0.0\overline{1}_3 &&& \\ \frac{1}{7} &= 0.\overline{010212}_3 &&& \ell(7) &= 6 \\ \frac{1}{8} &= 0.\overline{01}_3 &&& \ell(8) &= 2 \\ \frac{1}{9} &= 0.01_3 &&& \\ \frac{1}{10} &= 0.\overline{0022}_3 &&& \ell(10) &= 4 \\ \vdots \\ \frac{1}{20} &= 0.\overline{0011}_3 &&& \ell(20) &= 4 \\ \vdots \\ \frac{1}{30} &= 0.0\overline{0022}_3 &&& \\ \vdots \\ \frac{1}{35} &= 0.\overline{000202211101}_3 &&& \ell(35) &= 12 \\ \vdots \\ \end {aligned} } \)

\(\boxed{\frac{1}{2} = 0.\overline{1}_3}\)

\(N = 2\) is prime but is not a factor of the base. Therefore, the period is the smallest \(e\) such that \(N \mid (3^e - 1)\).

\( \begin{aligned} 1 \times b &= 3 &&= \textcolor{#0096FF}{1} \times N + 1 \\ \end {aligned} \)

\( \begin{aligned} 0.\overline{1}_3 &= 1 \times 3^{-1} + 1 \times 3^{-2} + 1 \times 3^{-3} + 1 \times 3^{-4} + 1 \times 3^{-5} + 1 \times 3^{-6} + \dotsb \\ &= 3^{-1} + 3^{-2} + 3^{-3} + 3^{-4} + 3^{-5} + 3^{-6} + \dotsb \\ &= 3^{-1} + (3^{-1})(3^{-1}) + (3^{-1})(3^{-1})^2 + (3^{-1})(3^{-1})^3 + (3^{-1})(3^{-1})^4 + (3^{-1})(3^{-1})^5 + \dotsb \\ &= 3^{-1} \times (1 + (3^{-1}) + (3^{-1})^2 + (3^{-1})^3 + (3^{-1})^4 + (3^{-1})^5 + \dotsb) \\ &= 3^{-1} \times \frac{1}{1 - \frac{1}{3}} \\ &= \frac{1}{3} \times \frac{3}{2} \\ &= \frac{1}{2} \\ \end {aligned} \)

\(\blacksquare\)

\(\boxed{\frac{1}{3} = 0.1_3}\)

\(N = 3\) only consists of prime factors of the base and so the ternary fraction terminates.

\( \begin{aligned} 1 \times b &= 3 &&= \textcolor{#0096FF}{1} \times N + 0 \\ \end {aligned} \)

\( \begin{aligned} 0.1_3 = 1 \times 3^{-1} = \frac{1}{3} \end {aligned} \)

\(\blacksquare\)

\(\boxed{\frac{1}{4} = 0.\overline{02}_3}\)

\(N = 4 = 2^2\). Therefore, the period is the smallest \(e\) such that \(N \mid (3^e - 1)\).

\( \begin{aligned} 1 \times b &= 3 &&= \textcolor{#0096FF}{0} \times N + 3 \\ 3 \times b &= 9 &&= \textcolor{#0096FF}{2} \times N + 1 \\ \end {aligned} \)

\( \begin{aligned} 0.\overline{02}_3 &= 0 \times 3^{-1} + 2 \times 3^{-2} + 0 \times 3^{-3} + 2 \times 3^{-4} + 0 \times 3^{-5} + 2 \times 3^{-6} + \dotsb \\ &= 2 \times 3^{-2} + 2 \times 3^{-4} + 2 \times 3^{-6} + \dotsb \\ &= 2 \times (3^{-2} + 3^{-4} + 3^{-6} + \dotsb) \\ &= 2 \times (3^{-2} + (3^{-2})(3^{-2}) + (3^{-2})(3^{-2})^2 + \dotsb) \\ &= 2 \times 3^{-2} \times (1 + (3^{-2}) + (3^{-2})^2 + \dotsb) \\ &= 2 \times 3^{-2} \times \frac{1}{1 - \frac{1}{9}} \\ &= 2 \times \frac{1}{9} \times \frac{9}{8} \\ &= \frac{1}{4} \\ \end {aligned} \)

\(\blacksquare\)

\(\boxed{\frac{1}{5} = 0.\overline{0121}_3}\)

\(N = 5\) is prime but is not a factor of the base. Therefore, the period is the smallest \(e\) such that \(N \mid (3^e - 1)\).

\( \begin{aligned} 1 \times b &= 3 &&= \textcolor{#0096FF}{0} \times N + 3 \\ 3 \times b &= 9 &&= \textcolor{#0096FF}{1} \times N + 4 \\ 4 \times b &= 12 &&= \textcolor{#0096FF}{2} \times N + 2 \\ 2 \times b &= 6 &&= \textcolor{#0096FF}{1} \times N + 1 \\ \end {aligned} \)

\( \begin{aligned} 0.\overline{0121}_3 &= 0 \times 3^{-1} + 1 \times 3^{-2} + 2 \times 3^{-3} + 1 \times 3^{-4} + 0 \times 3^{-5} + 1 \times 3^{-6} + 2 \times 3^{-7} + 1 \times 3^{-8} + \dotsb \\ &= (3^{-2} + 2 \times 3^{-3} + 3^{-4}) + (3^{-6} + 2 \times 3^{-7} + 3^{-8}) + (3^{-10} + 2 \times 3^{-11} + 3^{-12}) + \dotsb \\ &= (3^{-2} + 2 \times 3^{-3} + 3^{-4}) + (3^{-2} + 2 \times 3^{-3} + 3^{-4})(3^{-4}) + (3^{-2} + 2 \times 3^{-3} + 3^{-4})(3^{-4})^2 + \dotsb \\ &= (3^{-2} + 2 \times 3^{-3} + 3^{-4}) \times (1 + (3^{-4}) + (3^{-4})^2 + \dotsb) \\ &= (3^{-2} + 2 \times 3^{-3} + 3^{-4}) \times \frac{1}{1 - \frac{1}{81}} \\ &= \left( \frac{1}{9} + \frac{2}{27} + \frac{1}{81} \right) \times \frac{81}{80} \\ &= \frac{16}{81} \times \frac{81}{80} \\ &= \frac{1}{5} \\ \end {aligned} \)

\(\blacksquare\)

\(\boxed{\frac{1}{6} = 0.0\overline{1}_3}\)

\(N = 6 = 2 \times 3^1\) and \(\ell(2) = 1\). Therefore, the period is \(1\) and begins \(1\) digit after the radix point.

\( \begin{aligned} 1 \times b &= 3 &&= \textcolor{#0096FF}{0} \times N + 3 \\ 3 \times b &= 9 &&= \textcolor{#0096FF}{1} \times N + 3 \\ \end {aligned} \)

\( \begin{aligned} 0.\overline{0121}_3 &= 0 \times 3^{-1} + 1 \times 3^{-2} + 1 \times 3^{-3} + 1 \times 3^{-4} + 1 \times 3^{-5} + 1 \times 3^{-6} + \dotsb \\ &= 3^{-2} + 3^{-3} + 3^{-4} + 3^{-5} + 3^{-6} + \dotsb \\ &= 3^{-2} + (3^{-2})(3^{-1}) + (3^{-2})(3^{-1})^2 + (3^{-2})(3^{-1})^3 + (3^{-2})(3^{-1})^4 + \dotsb \\ &= 3^{-2} \times (1 + (3^{-1}) + (3^{-1})^2 + (3^{-1})^3 + (3^{-1})^4 + \dotsb) \\ &= 3^{-2} \times \frac{1}{1 - \frac{1}{3}} \\ &= \frac{1}{9} \times \frac{3}{2} \\ &= \frac{1}{6} \\ \end {aligned} \)

\(\blacksquare\)

\(\boxed{\frac{1}{7} = 0.\overline{010212}_3}\)

\(N = 7\) is prime but is not a factor of the base. Therefore, the period is the smallest \(e\) such that \(N \mid (3^e - 1)\).

\( \begin{aligned} 1 \times b &= 3 &&= \textcolor{#0096FF}{0} \times N + 3 \\ 3 \times b &= 9 &&= \textcolor{#0096FF}{1} \times N + 2 \\ 2 \times b &= 6 &&= \textcolor{#0096FF}{0} \times N + 6 \\ 6 \times b &= 18 &&= \textcolor{#0096FF}{2} \times N + 4 \\ 4 \times b &= 12 &&= \textcolor{#0096FF}{1} \times N + 5 \\ 5 \times b &= 15 &&= \textcolor{#0096FF}{2} \times N + 1 \\ \end {aligned} \)

\( \begin{aligned} 0.\overline{010212}_3 &= 0 \times 3^{-1} + 1 \times 3^{-2} + 0 \times 3^{-3} + 2 \times 3^{-4} + 1 \times 3^{-5} + 2 \times 3^{-6} + 0 \times 3^{-7} + 1 \times 3^{-8} + 0 \times 3^{-9} + 2 \times 3^{-10} + 1 \times 3^{-11} + 2 \times 3^{-12} + \dotsb \\ &= (3^{-2} + 2 \times 3^{-4} + 3^{-5} + 2 \times 3^{-6}) + (3^{-8} + 2 \times 3^{-10} + 3^{-11} + 2 \times 3^{-12}) + \dotsb \\ &= (3^{-2} + 2 \times 3^{-4} + 3^{-5} + 2 \times 3^{-6}) + (3^{-2} + 2 \times 3^{-4} + 3^{-5} + 2 \times 3^{-6})(3^{-6}) + \dotsb \\ &= (3^{-2} + 2 \times 3^{-4} + 3^{-5} + 2 \times 3^{-6}) \times (1 + (3^{-6}) + (3^{-6})^2 + \dotsb) \\ &= (3^{-2} + 2 \times 3^{-4} + 3^{-5} + 2 \times 3^{-6}) \times \frac{1}{1 - \frac{1}{729}} \\ &= \left( \frac{1}{9} + \frac{2}{81} + \frac{1}{243} + \frac{2}{729} \right) \times \frac{729}{728} \\ &= \frac{104}{729} \times \frac{729}{728} \\ &= \frac{1}{7} \end {aligned} \)

\(\blacksquare\)

\(\boxed{\frac{1}{8} = 0.\overline{01}_3}\)

\(N = 8 = 2^3\). Therefore, the period is the smallest \(e\) such that \(N \mid (3^e - 1)\).

\( \begin{aligned} 1 \times b &= 3 &&= \textcolor{#0096FF}{0} \times N + 3 \\ 3 \times b &= 9 &&= \textcolor{#0096FF}{1} \times N + 1 \\ \end {aligned} \)

\( \begin{aligned} 0.\overline{01}_3 &= 0 \times 3^{-1} + 1 \times 3^{-2} + 0 \times 3^{-3} + 1 \times 3^{-4} + 0 \times 3^{-5} + 1 \times 3^{-6} + \dotsb \\ &= 3^{-2} + 3^{-4} + 3^{-6} + \dotsb \\ &= 3^{-2} + (3^{-2})(3^{-2}) + (3^{-2})(3^{-2})^2 + \dotsb \\ &= 3^{-2} \times (1 + (3^{-2}) + (3^{-2})^2 + \dotsb) \\ &= 3^{-2} \times \frac{1}{1 - \frac{1}{9}} \\ &= \frac{1}{9} \times \frac{9}{8} \\ &= \frac{1}{8} \\ \end {aligned} \)

\(\blacksquare\)

\(\boxed{\frac{1}{9} = 0.01_3}\)

\(N = 9 = 3^2\) only consists of prime factors of the base and so the ternary fraction terminates.

\( \begin{aligned} 1 \times b &= 3 &&= \textcolor{#0096FF}{0} \times N + 3 \\ 3 \times b &= 9 &&= \textcolor{#0096FF}{1} \times N + 0 \\ \end {aligned} \)

\( \begin{aligned} 0.01_3 = 1 \times 3^{-2} = \frac{1}{9} \end {aligned} \)

\(\blacksquare\)

\(\boxed{\frac{1}{10} = 0.\overline{0022}_3}\)

\(N = 10 = 2 \times 5\) is a product of prime powers none of which are factors of the base. Thus the period is \(\text{lcm}[\ell(2) = 1, \ell(5) = 4] = 4\).

\( \begin{aligned} 1 \times b &= 3 &&= \textcolor{#0096FF}{0} \times N + 3 \\ 3 \times b &= 9 &&= \textcolor{#0096FF}{0} \times N + 9 \\ 9 \times b &= 27 &&= \textcolor{#0096FF}{2} \times N + 7 \\ 7 \times b &= 21 &&= \textcolor{#0096FF}{2} \times N + 1 \\ \end {aligned} \)

\( \begin{aligned} 0.\overline{0022}_3 &= 0 \times 3^{-1} + 0 \times 3^{-2} + 2 \times 3^{-3} + 2 \times 3^{-4} + 0 \times 3^{-5} + 0 \times 3^{-6} + 2 \times 3^{-7} + 2 \times 3^{-8} + \dotsb \\ &= (2 \times 3^{-3} + 2 \times 3^{-4}) + (2 \times 3^{-7} + 2 \times 3^{-8}) + \dotsb \\ &= 2 \times ((3^{-3} + 3^{-4}) + (3^{-7} + 3^{-8}) + \dotsb) \\ &= 2 \times ((3^{-3} + 3^{-4}) + (3^{-3} + 3^{-4})(3^{-4}) + (3^{-3} + 3^{-4})(3^{-4})^2 + \dotsb) \\ &= 2 \times (3^{-3} + 3^{-4}) \times (1 + (3^{-4}) + (3^{-4})^2 + \dotsb) \\ &= 2 \times (3^{-3} + 3^{-4}) \times \frac{1}{1 - \frac{1}{81}} \\ &= \left( \frac{2}{27} + \frac{2}{81} \right) \times \frac{81}{80} \\ &= \frac{8}{81} \times \frac{81}{80} \\ &= \frac{1}{10} \\ \end {aligned} \)

\(\blacksquare\)

\(\boxed{\frac{1}{20} = 0.\overline{0011}_3}\)

\(N = 20 = 2^2 \times 5\) is a product of prime powers none of which are factors of the base. Thus the period is \(\text{lcm}[\ell(4) = 2, \ell(5) = 4] = 4\).

\( \begin{aligned} 1 \times b &= 3 &&= \textcolor{#0096FF}{0} \times N + 3 \\ 3 \times b &= 9 &&= \textcolor{#0096FF}{0} \times N + 9 \\ 9 \times b &= 27 &&= \textcolor{#0096FF}{1} \times N + 7 \\ 7 \times b &= 21 &&= \textcolor{#0096FF}{1} \times N + 1 \\ \end {aligned} \)

\( \begin{aligned} 0.\overline{0011}_3 &= 0 \times 3^{-1} + 0 \times 3^{-2} + 1 \times 3^{-3} + 1 \times 3^{-4} + 0 \times 3^{-5} + 0 \times 3^{-6} + 1 \times 3^{-7} + 1 \times 3^{-8} + \dotsb \\ &= (3^{-3} + 3^{-4}) + (3^{-7} + 3^{-8}) + \dotsb \\ &= (3^{-3} + 3^{-4}) + (3^{-3} + 3^{-4})(3^{-4}) + (3^{-3} + 3^{-4})(3^{-4})^2 + \dotsb \\ &= (3^{-3} + 3^{-4}) \times (1 + (3^{-4}) + (3^{-4})^2 + \dotsb) \\ &= (3^{-3} + 3^{-4}) \times \frac{1}{1 - \frac{1}{81}} \\ &= \left( \frac{1}{27} + \frac{1}{81} \right) \times \frac{81}{80} \\ &= \frac{4}{81} \times \frac{81}{80} \\ &= \frac{1}{20} \\ \end {aligned} \)

\(\blacksquare\)

\(\boxed{\frac{1}{30} = 0.0\overline{0022}_3}\)

\(N = 30 = 2 \times 3 \times 5\) is a product of prime powers one of which is a factor of the base. Thus the period is \(\text{lcm}[\ell(4) = 2, \ell(5) = 4] = 4\) and it begins \(1\) digit after the radix point.

\( \begin{aligned} 1 \times b &= 3 &&= \textcolor{#0096FF}{0} \times N + 3 \\ 3 \times b &= 9 &&= \textcolor{#0096FF}{0} \times N + 9 \\ 9 \times b &= 27 &&= \textcolor{#0096FF}{0} \times N + 27 \\ 27 \times b &= 81 &&= \textcolor{#0096FF}{2} \times N + 21 \\ 21 \times b &= 63 &&= \textcolor{#0096FF}{2} \times N + 3 \\ \end {aligned} \)

\( \begin{aligned} 0.0\overline{0022}_3 &= 0 \times 3^{-1} + 0 \times 3^{-2} + 0 \times 3^{-3} + 2 \times 3^{-4} + 2 \times 3^{-5} + 0 \times 3^{-6} + 0 \times 3^{-7} + 2 \times 3^{-8} + 2 \times 3^{-9} + \dotsb \\ &= (2 \times 3^{-4} + 2 \times 3^{-5}) + (2 \times 3^{-8} + 2 \times 3^{-9}) + \dotsb \\ &= 2 \times ((3^{-4} + 3^{-5}) + (3^{-8} + 3^{-9}) + \dotsb) \\ &= 2 \times ((3^{-4} + 3^{-5}) + (3^{-4} + 3^{-5})(3^{-4}) + (3^{-4} + 3^{-5})(3^{-4})^2 + \dotsb) \\ &= 2 \times (3^{-4} + 3^{-5}) \times (1 + (3^{-4}) + (3^{-4})^2 + \dotsb) \\ &= 2 \times (3^{-4} + 3^{-5}) \times \frac{1}{1 - \frac{1}{81}} \\ &= \left( \frac{2}{81} + \frac{2}{243} \right) \times \frac{81}{80} \\ &= \frac{8}{243} \times \frac{81}{80} \\ &= \frac{1}{30} \\ \end {aligned} \)

\(\blacksquare\)

\(\boxed{\frac{1}{35} = 0.\overline{000202211101}}\)

\(N = 35 = 5 \times 7\) is a product of prime powers none of which are factors of the base. Thus the period is \(\text{lcm}[\ell(5) = 4, \ell(7) = 6] = 12\).

\( \begin{aligned} 1 \times b &= 3 &&= \textcolor{#0096FF}{0} \times N + 3 \\ 3 \times b &= 9 &&= \textcolor{#0096FF}{0} \times N + 9 \\ 9 \times b &= 27 &&= \textcolor{#0096FF}{0} \times N + 27 \\ 27 \times b &= 81 &&= \textcolor{#0096FF}{2} \times N + 11 \\ 11 \times b &= 33 &&= \textcolor{#0096FF}{0} \times N + 33 \\ 33 \times b &= 99 &&= \textcolor{#0096FF}{2} \times N + 29 \\ 29 \times b &= 87 &&= \textcolor{#0096FF}{2} \times N + 17 \\ 17 \times b &= 51 &&= \textcolor{#0096FF}{1} \times N + 16 \\ 16 \times b &= 48 &&= \textcolor{#0096FF}{1} \times N + 13 \\ 13 \times b &= 39 &&= \textcolor{#0096FF}{1} \times N + 4 \\ 4 \times b &= 12 &&= \textcolor{#0096FF}{0} \times N + 12 \\ 12 \times b &= 36 &&= \textcolor{#0096FF}{1} \times N + 1 \\ \end {aligned} \)

\( \begin{aligned} \frac{1}{35} = 0.\overline{000202211101} &= 0 \times 3^{-1} + 0 \times 3^{-2} + 0 \times 3^{-3} + 2 \times 3^{-4} + 0 \times 3^{-5} + 2 \times 3^{-6} + 2 \times 3^{-7} + 1 \times 3^{-8} + 1 \times 3^{-9} + 1 \times 3^{-10} + 0 \times 3^{-11} + 1 \times 3^{-12} + \dotsb \\ &= (2 \times 3^{-4} + 2 \times 3^{-6} + 2 \times 3^{-7} + 3^{-8} + 3^{-9} + 3^{-10} + 3^{-12}) + \dotsb \\ &= \dots \\ &= \frac{1}{35} \\ \end {aligned} \)

\(\blacksquare\)

import decimal
import math
decimal.getcontext().prec = 250
m = 3**39 - 1
n = 30
decimal.Decimal(m)/decimal.Decimal(n)

# e = 1
# while True:
#   e += 1
#   m = 3**e - 1
#   n = 30
#   frac, _ = math.modf(decimal.Decimal(m)/decimal.Decimal(n))
#   if frac == 0:
#     print(e)
#     break
Decimal('135085171767299208.8666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666667')



Acknowledgements#

TJOF 2013 Wagstaff Jr., Samuel S. The Joy of Factoring. AMS Student Mathematical Library.