HP Forums
(12C) Modulo Operation - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: General Software Library (/forum-13.html)
+--- Thread: (12C) Modulo Operation (/thread-21973.html)



(12C) Modulo Operation - Gamo - 06-30-2024 05:15 AM

Modulo (MOD) operation returns the remainder of a division.

All the HP Voyager Series (10, 11, 12 and 15) not include

the MOD function except the 16.

------------------------------------------------------------------

Let's calculate this MOD Operation manually.

example: 1155 MOD 13

1155 [ENTER] 13

►[ENTER] [ENTER] [-] [R↓] [X<>Y] [LSTx] [÷] [INTG] [x] [-]

Display Answer 11

With this manually key in operation can be easily input those
keys sequence as a program start from ► the whole line.
------------------------------------------------------------------
Once key in as a program let's try one more example.

How many years from 1983 to 2024 instead of simple subtraction
let's use this MOD operation.

2024 [ENTER] 1983 [R/S] display answer 41
-------------------------------------------------------------------

Gamo 6/2024


RE: (12C) Modulo Operation - C.Ret - 06-30-2024 11:20 AM

(06-30-2024 05:15 AM)Gamo Wrote:  Let's calculate this MOD Operation manually.
example: 1155 MOD 13
1155 [ENTER] 13 ► [ENTER] [ENTER] [-] [R↓] [X<>Y] [LSTx] [÷] [INTG] [x] [-] ► Display Answer 11

May I suggest a slightly shorter alternative solution to use from the ► starting point:
[Image: attachment.php?aid=13676]


RE: (12C) Modulo Operation - Albert Chan - 06-30-2024 04:30 PM

(07-31-2018 06:10 PM)Albert Chan Wrote:  Register Y X --> X Mod(Y, X)

Keep pressing R/S, eventually it display 0, previous Mod was Gcd (Rotate key to get it back)

Code:
                ; HP-12C Mod Program: Y X --> X Mod(Y, X)
Enter Enter     ; Y X X X
- LastX +       ; Y Y X X
Rotate          ; X Y Y X
/ LastX Swap    ; X Y X Y/X
Int * -         ; X X X Mod(Y,X)

From my old post, we can have mod get gcd as well