How to resolve the algorithm Greatest common divisor step by step in the ERRE programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Greatest common divisor step by step in the ERRE programming language
Table of Contents
Problem Statement
Find the greatest common divisor (GCD) of two integers.
Greatest common divisor is also known as greatest common factor (gcf) and greatest common measure.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Greatest common divisor step by step in the ERRE programming language
Source code in the erre programming language
PROGRAM EUCLIDE
! calculate G.C.D. between two integer numbers
! using Euclidean algorithm
!VAR J%,K%,MCD%,A%,B%
BEGIN
PRINT(CHR$(12);"Input two numbers : ";) !CHR$(147) in C-64 version
INPUT(J%,K%)
A%=J% B%=K%
WHILE A%<>B% DO
IF A%>B%
THEN
A%=A%-B%
ELSE
B%=B%-A%
END IF
END WHILE
MCD%=A%
PRINT("G.C.D. between";J%;"and";K%;"is";MCD%)
END PROGRAM
You may also check:How to resolve the algorithm Loops/N plus one half step by step in the Aime programming language
You may also check:How to resolve the algorithm Numerical integration/Gauss-Legendre Quadrature step by step in the PARI/GP programming language
You may also check:How to resolve the algorithm Luhn test of credit card numbers step by step in the Octave programming language
You may also check:How to resolve the algorithm Day of the week step by step in the GAP programming language
You may also check:How to resolve the algorithm MAC vendor lookup step by step in the UNIX Shell programming language