Post Reply 
Find LCM of 2 numbers without using GCD
08-02-2018, 01:25 AM (This post was last modified: 08-02-2018 06:58 PM by Albert Chan.)
Post: #23
RE: Find LCM of 2 numbers without using GCD
Here is my revised Mod/Gcd program for HP-12C

If Y, X both negative, it does Gcd(Y, X)
If Y, X both positive, it does Mod(Y, X)
If X = 0, return Y

Example:

54321 CHS Enter 12345 CHS
R/S => -3 ; Gcd

54321 Enter 12345
R/S => 4941 ; Mod(54321, 12345)
R/S => 2463 ; Mod(12345, 4941)
R/S => 15 ; Mod(4941, 2463)
R/S => 3 ; Mod(2463, 15)
R/S => 0 ; Mod(15, 3)
R/S => 3 ; Gcd

Code:
01 X = 0
02 GOTO 17
03 ENTER
04 ENTER
05 CLX
06 +
07 R↓
08 /
09 Lstx
10 X<>Y
11 INTG
12 *
13 -
14 X <= Y    ; Mod ?
15 GOTO 00
16 GOTO 01
17 +
18 GOTO 00
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Find LCM of 2 numbers without using GCD - Albert Chan - 08-02-2018 01:25 AM



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