Post Reply 
Request for "Decimal Period of 1/X in Base Y" program
08-11-2019, 07:00 PM (This post was last modified: 08-13-2019 09:55 PM by Albert Chan.)
Post: #27
RE: Request for "Decimal Period of 1/X in Base Y" program
(03-01-2015 06:17 PM)Joe Horn (post 18) Wrote:  Uh oh. Running it after 12 ENTER 23 yields 22, but the correct answer for the period of 1/23 in base 12
(as returned by my URPL program above) is 11, as can be seen by actually writing 1/23 in base 12:

0.06316948421 06316948421 06316948421 06316948421 ...

Am I misunderstanding something here?

The code for order(a,n) were wrong. order(12,23) = 11, matching repeating decimals period.

GCD does 2 duties: satisfy order() co-prime arguments requirement, and to track where to put the "decimal" point.

Example, 1/360 to base 12

12/360 = 1/30
12/30 = 2/5
Stop further scaling since gcd(12,5) = 1

order(12,5) = 4
12^4-1 = 20735

2/5 = (20735*2/5) / 20735 = 8294/20735 = 4972/BBBB (base 12)

1/360 = 0.00 \(\overline{4972}\) (base 12)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Request for "Decimal Period of 1/X in Base Y" program - Albert Chan - 08-11-2019 07:00 PM



User(s) browsing this thread: 6 Guest(s)