Request for "Decimal Period of 1/X in Base Y" program - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: HP Prime (/forum-5.html) +--- Thread: Request for "Decimal Period of 1/X in Base Y" program (/thread-3212.html) Pages: 1 2 |
RE: Request for "Multiplicative Order of Y (mod X)" program - Gerald H - 03-01-2015 10:17 PM If you want to do it for any base, instead of removing 2s & 5s, remove any factors of that base & change the 10 near the end for the required base - I believe that will solve it. It might be an idea to change title of thread so others can find solution to length of period problem. RE: Request for "Decimal Period of 1/X in Base Y" program - Joe Horn - 03-02-2015 07:09 AM (03-01-2015 10:17 PM)Gerald H Wrote: If you want to do it for any base, instead of removing 2s & 5s, remove any factors of that base & change the 10 near the end for the required base - I believe that will solve it. Will try that. I hope it's a valid method, because that's the method used by my URPL program, but it's much slower than yours. Quote:It might be an idea to change title of thread so others can find solution to length of period problem. Good idea. Done. RE: Request for "Decimal Period of 1/X in Base Y" program - Gerald H - 03-02-2015 08:10 AM (03-01-2015 05:40 PM)Joe Horn Wrote:(02-27-2015 09:57 AM)Gerald H Wrote: IF you're only interested in integer values for X & Y, this 50G prog does the job: ... Sorry, it's a custom EXTABLE for ROM 2.10-7. Yes, Z0_ is ZINT 0. RE: Request for "Decimal Period of 1/X in Base Y" program - Gerald H - 03-02-2015 10:33 AM (03-02-2015 07:09 AM)Joe Horn Wrote:(03-01-2015 10:17 PM)Gerald H Wrote: If you want to do it for any base, instead of removing 2s & 5s, remove any factors of that base & change the 10 near the end for the required base - I believe that will solve it. OK, how about this prog: « WHILE DUP PICK3 GCD DUP 1 > REPEAT / END DROP SWAP ORD » RE: Request for "Decimal Period of 1/X in Base Y" program - StephenG1CMZ - 01-21-2018 09:17 PM (02-27-2015 08:49 AM)Thomas Ritschel Wrote: Here is a simple non-CAS variant: I am using this procedure to analyze repeating decimals/recurring decimals here: http://www.hpmuseum.org/forum/thread-9986.html RE: Request for "Decimal Period of 1/X in Base Y" program - StephenG1CMZ - 01-26-2018 11:32 PM I now have an optimised version of MultiplicativeOrder for base 10 on the Prime here: http://www.hpmuseum.org/forum/thread-9986.html RE: Request for "Decimal Period of 1/X in Base Y" program - Albert Chan - 08-11-2019 07:00 PM (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 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) |