Greatest common divisor: Difference between revisions

Add bruijn
(Add PowerPC Assembly example)
(Add bruijn)
 
(2 intermediate revisions by 2 users not shown)
Line 152:
bge _gcd
mr r5, r3
mr r4r3, r3r4
mr r3r4, r5
_gcd:
cmpdi r4, 0
Line 2,300:
<pre>{?} gcd$(49865.69811)
{!} 9973</pre>
 
=={{header|Bruijn}}==
As defined in <code>std/Math</code>.
<syntaxhighlight lang="bruijn">
:import std/Combinator .
:import std/Number .
 
gcd y [[[=?0 1 (2 0 (1 % 0))]]]
 
:test ((gcd (+2) (+4)) =? (+2)) ([[1]])
:test ((gcd (+10) (+5)) =? (+5)) ([[1]])
:test ((gcd (+3) (+8)) =? (+1)) ([[1]])
</syntaxhighlight>
 
=={{header|C}}==
Line 5,760 ⟶ 5,773:
m
]</syntaxhighlight>
 
=={{header|Refal}}==
<syntaxhighlight lang="refal">$ENTRY Go {
= <Prout <Gcd 3528 3780>>;
};
 
Gcd {
s.M 0 = s.M;
s.M s.N = <Gcd s.N <Mod s.M s.N>>;
};</syntaxhighlight>
{{out}}
<pre>252</pre>
 
=={{header|Retro}}==
55

edits