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
 Albert Chan Senior Member Posts: 722 Joined: Jul 2018
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)
 « Next Oldest | Next Newest »

 Messages In This Thread Request for "Decimal Period of 1/X in Base Y" program - Joe Horn - 02-27-2015, 06:13 AM RE: Request for "Multiplicative Order of Y (mod X)" program - Thomas Ritschel - 02-27-2015, 08:49 AM RE: Request for "Decimal Period of 1/X in Base Y" program - StephenG1CMZ - 01-21-2018, 09:17 PM RE: Request for "Multiplicative Order of Y (mod X)" program - Gerald H - 02-27-2015, 09:35 AM RE: Request for "Multiplicative Order of Y (mod X)" program - Gerald H - 02-27-2015, 09:57 AM RE: Request for "Multiplicative Order of Y (mod X)" program - rprosperi - 02-27-2015, 01:55 PM RE: Request for "Multiplicative Order of Y (mod X)" program - Joe Horn - 02-27-2015, 04:01 PM RE: Request for "Multiplicative Order of Y (mod X)" program - Gerald H - 02-27-2015, 04:34 PM RE: Request for "Multiplicative Order of Y (mod X)" program - Gerald H - 02-28-2015, 07:30 AM RE: Request for "Multiplicative Order of Y (mod X)" program - Gerald H - 02-28-2015, 09:39 AM RE: Request for "Multiplicative Order of Y (mod X)" program - Joe Horn - 02-28-2015, 01:14 PM RE: Request for "Multiplicative Order of Y (mod X)" program - Gerald H - 02-28-2015, 01:56 PM RE: Request for "Multiplicative Order of Y (mod X)" program - Joe Horn - 03-01-2015, 01:21 AM RE: Request for "Multiplicative Order of Y (mod X)" program - Gerald H - 03-01-2015, 06:28 AM RE: Request for "Multiplicative Order of Y (mod X)" program - Joe Horn - 03-01-2015, 05:40 PM RE: Request for "Decimal Period of 1/X in Base Y" program - Gerald H - 03-02-2015, 08:10 AM RE: Request for "Multiplicative Order of Y (mod X)" program - Gerald H - 03-01-2015, 08:18 AM RE: Request for "Multiplicative Order of Y (mod X)" program - Gerald H - 03-01-2015, 09:04 AM RE: Request for "Multiplicative Order of Y (mod X)" program - Gerald H - 03-01-2015, 09:48 AM RE: Request for "Multiplicative Order of Y (mod X)" program - Joe Horn - 03-01-2015, 06:17 PM RE: Request for "Multiplicative Order of Y (mod X)" program - Gerald H - 03-01-2015, 07:02 PM RE: Request for "Multiplicative Order of Y (mod X)" program - Joe Horn - 03-01-2015, 09:55 PM RE: Request for "Decimal Period of 1/X in Base Y" program - Albert Chan - 08-11-2019 07:00 PM RE: Request for "Multiplicative Order of Y (mod X)" program - Gerald H - 03-01-2015, 10:17 PM RE: Request for "Decimal Period of 1/X in Base Y" program - Joe Horn - 03-02-2015, 07:09 AM RE: Request for "Decimal Period of 1/X in Base Y" program - Gerald H - 03-02-2015, 10:33 AM RE: Request for "Decimal Period of 1/X in Base Y" program - StephenG1CMZ - 01-26-2018, 11:32 PM

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