Greatest common divisor: Difference between revisions
Content added Content deleted
(added go) |
m (→{{header|PowerShell}}: some whitespace to make reading easier) |
||
Line 1,054: | Line 1,054: | ||
=={{header|PowerShell}}== |
=={{header|PowerShell}}== |
||
===Recursive Euclid Algorithm=== |
===Recursive Euclid Algorithm=== |
||
<lang powershell>function |
<lang powershell>function Get-GCD ($x, $y) |
||
{ |
{ |
||
if($x-eq$y){ return $y } |
if ($x -eq $y) { return $y } |
||
if($x-gt$y){ |
if ($x -gt $y) { |
||
$a=$x |
$a = $x |
||
$b=$y |
$b = $y |
||
} |
} |
||
else { |
else { |
||
$a=$y |
$a = $y |
||
$b=$x |
$b = $x |
||
} |
} |
||
while |
while ($a % $b -ne 0) { |
||
$tmp=$a%$b |
$tmp = $a % $b |
||
$a=$b |
$a = $b |
||
$b=$tmp |
$b = $tmp |
||
} |
} |
||
return $b |
return $b |