Greatest common divisor: Difference between revisions
Content deleted Content added
m →{{header|Oforth}}: Change of rem by mod |
→{{header|PowerShell}}: port short Python implementation |
||
Line 2,453:
return $b
}</lang>
or shorter (taken from Python implementation)
<lang powershell>function Get-GCD ($x, $y) {
if ($y -eq 0) { $x } else { Get-GCD $y ($x%$y) }
}</lang>
===Iterative Euclid Algorithm===
based on Python implementation
<lang powershell>
Function Get-GCD( $x, $y ) {
while ($y -ne 0) {
$x, $y = $y, ($x % $y)
}
[Math]::abs($x)
}
</lang>
=={{header|Prolog}}==
|