Greatest common divisor: Difference between revisions
Content added Content deleted
Line 111: | Line 111: | ||
⌈/(^/0=A∘.|X)/A←⍳⌊/X←49865 69811 |
⌈/(^/0=A∘.|X)/A←⍳⌊/X←49865 69811 |
||
9973 |
9973 |
||
=={{header|AutoIt}} |
|||
<lang autoit> |
|||
_GCD(18, 12) |
|||
_GCD(1071, 1029) |
|||
_GCD(3528, 3780) |
|||
Func _GCD($ia, $ib) |
|||
Local $ret = "GCD of " & $ia & " : " & $ib & " = " |
|||
Local $imod |
|||
While True |
|||
$imod = Mod($ia, $ib) |
|||
If $imod = 0 Then Return ConsoleWrite($ret & $ib & @CRLF) |
|||
$ia = $ib |
|||
$ib = $imod |
|||
WEnd |
|||
EndFunc ;==>_GCD |
|||
</lang> |
|||
Output: <pre>GCD of 18 : 12 = 6 |
|||
GCD of 1071 : 1029 = 21 |
|||
GCD of 3528 : 3780 = 252</pre> |
|||
=={{header|AWK}}== |
=={{header|AWK}}== |