Post Reply 
(32SII) Solving a Single Congruence Equation for the HP 32Sii
01-16-2014, 03:16 AM (This post was last modified: 06-15-2017 01:30 PM by Gene.)
Post: #1
(32SII) Solving a Single Congruence Equation for the HP 32Sii
The program solves for x in the equation:

A * x = B mod N

Examples:

4 * x = 6 mod 7
A = 4, B = 6, N = 7
Solution: 5

5 * x = 3 mod 17
A = 5, B = 3, N = 17
Solution: 4

11 * x = 3 mod 16
A = 11, B = 3, N = 16
Solution: 9

Main Routine: Label C
Subroutines: D, E
No pre-storing any variables required. If there is no solution, an error is produced.
To Run: XEQ C

Code:

C01 LBL C
C02 INPUT A
C03 INPUT B
C04 INPUT N
C05 1
C06 STO I

D01 LBL D
D02 RCL I
D03 RCL × A
D04 RCL - B
D05 RCL ÷ N
D06 FP
D07 x ≠ 0?
D08 GTO E
D09 RCL I
D010 RTN

E01 LBL E
E02 1
E03 STO + I
E04 RCL I
E05 RCL N
E06 x > y?
E07 GTO D
E08 0
E09 1/x
E10 RTN
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(32SII) Solving a Single Congruence Equation for the HP 32Sii - Eddie W. Shore - 01-16-2014 03:16 AM



User(s) browsing this thread: 1 Guest(s)