HP Forums
modulo calculation: inverse of a number - 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: modulo calculation: inverse of a number (/thread-5668.html)



modulo calculation: inverse of a number - StephanP - 02-11-2016 12:32 PM

Is it possible to have Prime calculate the inverse of a number mod(m)?
Example: the inverse of 3 mod 14 = 5


RE: modulo calculation: inverse of a number - parisse - 02-11-2016 05:24 PM

The class of x in Z/nZ is represented by x %% n, you can do arithmetic operations on these objects (including polynomials having them as coefficients).
a:=(3 %% 14)^-1
The class residue is represented with x between -n/2 and n/2.
Use %% 0 to extract the integer (for example a %% 0 will return 5 here).


RE: modulo calculation: inverse of a number - Gerald H - 02-11-2016 06:21 PM

Very interesting.

Also capable of finding square roots modulo, eg

SQRT(84%%(541*101)) = 24911

Nice.


RE: modulo calculation: inverse of a number - StephanP - 02-11-2016 07:09 PM

Thank you very much, but I may recquire a little more help to that.
Maybe it's the bad lighting conditions in my study, but where do I find the %%?
I'm also new to CAS, so if this is CAS-stuff, then I can do with a pointer to some quick start guide on CAS as well.

Much appreciated.


RE: modulo calculation: inverse of a number - Gerald H - 02-11-2016 07:52 PM

In CAS environment actuate toolbox key, scroll to %, "enter, remove () from input line", repeat the operations in quotes & you have %%.


RE: modulo calculation: inverse of a number - Tim Wessman - 02-11-2016 08:09 PM

Easier probably - do SHIFT CHARS (the Vars key shift function) - and tap on the % sign, tap ECHO at the bottom of the screen twice, and then press ENTER. I probably should add % to the quick char menu on shift 9 too...


Side note - we will most likely by REMOVING the current %( ) function and replacing it with something like %PER( ) or similar in order to eliminate the need for the double %% thing for CAS modulo (name conflict). We'd wanted to do that in the beginning, but managers at the time heard that by doing it would "change a function from the 39g" and pretty much squashed it. No matter that all it does is divide the two numbers...

Anyway, this should be much nicer at some point in the future.


RE: modulo calculation: inverse of a number - Gerald H - 02-11-2016 08:26 PM

Thank you, Tim, much more efficient for %%.

Modulo calculations go very nicely on Prime, sadly I won't enjoy them too much,
50g more convenient & I quote Stephan P

"Maybe it's the bad lighting conditions in my study, but where do I find the %%?"

keyboard colouration prohibits my usage.