Post Reply 
(12C) Greatest Common Divisor
01-06-2018, 12:29 AM (This post was last modified: 01-07-2018 02:35 AM by Gamo.)
Post: #1
(12C) Greatest Common Divisor
Quick and Simple program to find GCD of two integers.

Code:

 -
LSTx
X<>Y
ENTER
 x
 √
X=0
GTO 10
GTO 01
X<>Y

Thanks to Dieter for the trick by make sure that Y is greater than X so ABS don't have to be use and here is the update program.

Code:

X≤Y
X<>Y
X<>Y
  -
LSTx
X<>Y
X=0
GTO 10
GTO 01
X<>Y

Example:
Test 1 GCD (256, 656) is 16 ---> 256 ENTER 656 R/S
Test 2 GCD (12345, 67890) is 15 ---> 12345 ENTER 67890 R/S

Remark: Test 2 will run faster on HP 12C+

Gamo
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(12C) Greatest Common Divisor - Gamo - 01-06-2018 12:29 AM
RE: (12C) Greatest Common Divisor - Carsen - 01-06-2018, 01:10 AM
RE: (12C) Greatest Common Divisor - Gamo - 01-06-2018, 04:23 AM
RE: (12C) Greatest Common Divisor - Gamo - 10-08-2021, 08:08 AM
RE: (12C) Greatest Common Divisor - Gamo - 01-26-2022, 07:35 AM



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