HP 50g Graphing Calculator User Manual

Page 193

Advertising
background image

Page 5-16

operating on them. You can also convert any number into a ring number by
using the function EXPANDMOD. For example,

EXPANDMOD(125)

≡ 5 (mod 12)

EXPANDMOD(17)

≡ 5 (mod 12)

EXPANDMOD(6)

≡ 6 (mod 12)

The modular inverse of a number
Let a number k belong to a finite arithmetic ring of modulus n, then the modular
inverse of k, i.e., 1/k (mod n), is a number j, such that j

k

1 (mod n). The

modular inverse of a number can be obtained by using the function INVMOD
in the MODULO sub-menu of the ARITHMETIC menu. For example, in modulus
12 arithmetic:

1/6 (mod 12) does not exist.

1/5

≡ 5 (mod 12)

1/7

≡ -5 (mod 12)

1/3 (mod 12) does not exist.

1/11

≡ -1 (mod 12)

The MOD operator
The MOD operator is used to obtain the ring number of a given modulus
corresponding to a given integer number. On paper this operation is written
as m mod n = p, and is read as “m modulo n is equal to p”. For example, to
calculate 15 mod 8, enter:

Θ ALG mode:

15

MOD 8`

Θ RPN mode:

15`8`

MOD

The result is 7, i.e., 15 mod 8 = 7. Try the following exercises:
18 mod 11 = 7

23 mod 2 =1

40 mod 13 = 1

23 mod 17 = 6

34 mod 6 = 4

One practical application of the MOD function for programming purposes is to
determine when an integer number is odd or even, since n mod 2 = 0, if n is
even, and n mode 2 = 1, if n is odd. It can also be used to determine when an
integer m is a multiple of another integer n, for if that is the case m mod n = 0.

Advertising