Greatest common divisor: Difference between revisions

Added Euler
(Added Euler)
Line 2,954:
Input two numbers : ? 112,44
G.C.D. between 112 and 44 is 4
 
=={{header|Euler}}==
The original Euler didn't have built-in loops, this defines a while-loop procedure, as in the [[Steady Squares#Euler]] sample.
<br>
'''begin'''
'''new''' while; '''new''' gcd;
while <- ` '''formal''' condition; '''formal''' loopBody;
begin
'''label''' again;
again: '''if''' condition '''then''' '''begin''' loopBody; '''goto''' again '''end''' '''else''' 0
'''end'''
'
;
gcd <- ` '''formal''' m; '''formal''' n;
'''begin'''
'''new''' a; '''new''' b; '''new''' newA;
a <- '''abs''' m;
b <- '''abs''' n;
while( ` b <> 0 '
, ` '''begin'''
newA <- b;
b <- a mod b;
a <- newA
'''end'''
'
);
a
'''end'''
'
;
'''out''' gcd( -21, 35 )
'''end''' $
 
=={{header|Euler Math Toolbox}}==
3,038

edits