(03-01-2015 01:21 AM)Joe Horn Wrote: (02-28-2015 01:56 PM)Gerald H Wrote: No, the meaning is that if GCD of the two numbers is greater than one then NO power of that number is equal to one modulo the 2nd number.
Understood. But what I'm looking for is "the period of 1/X in base Y". It's only slowly dawning on me that this is NOT the same as "the order of Y mod X". Wolfram Mathworld says, "The number of digits in the repeating portion of the decimal expansion of a rational number can also be found directly from the multiplicative order of its denominator." But that assumes that the multiplicative order of the denominator exists, which apparently is not true, even when it *is* a repeating decimal. Example: 1/14 is a repeating decimal with a period of 6, and that's why my program returns 6 for an input of 10 & 14. But Mathematica's MultiplicativeOrder(10,14) refuses to return an answer for the reason you cited (10 and 14 are not coprime), just like Thomas' Prime program (which runs forever until halted by the user). So, how would you suggest calculating the period of the repeating decimal of 1/x where x is not coprime with 10?
Please accept my apology if it seems like I'm changing the subject, which I might be doing inadvertently! When I started this thread, I had thought that "period of 1/x base y" was the same as "order of y mod x" once the GCD of x and y was removed from x (which is why my program starts by removing the GCD). That's certainly true when y=10. Can it be false for y<>10? Thanks in advance for teaching this student who is always eager to learn.
For that you should read this:
http://mathworld.wolfram.com/DecimalExpansion.html
I have edited out my misleading comment.