## HP15c program: Calculate y mod x

```command         display

f LBL B        001-42,21,12
STO 3        002-    44 3       (store X in reg3)
x><y         003-      34
STO 4        004-    44 4       (store Y in reg4)
x><y         005-      34
divide       006-      10
g int          007-   43 44
RCL 3        008-    45 3
*            009-      20
CHS          010-      16
RCL 4        011-    45 4
+            012-      40
g RTN          013-   43 32
```

This program uses the following label: LBL B
The program uses STO register 3 and 4.

### Using the program

The modulus of Y mod X is an integer number smaller than X and the reminder of y divided by x. Enter Y and X and then press "GSB B" The modulus is the number that is in X after the execution of the program.

### The algorithm

The HP15c has an integer function to convert a floating point number into an integer number. We can use this to calculate the modulus:

y mod x = y - (x * int( y/x ))

Example to test the program:
15 mod 6 = 3
```15
Enter
6
GSB B

Expected result (shown in the display):
3
```