Jump to content

Greatest common divisor: Difference between revisions

→‎{{header|PowerShell}}: port short Python implementation
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}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.