Greatest common divisor: Difference between revisions
Content added Content deleted
(Added an Algol W sample) |
(Added LFE example) |
||
Line 1,523: | Line 1,523: | ||
{{VI snippet}}<br/> |
{{VI snippet}}<br/> |
||
[[File:LabVIEW Greatest common divisor.png]] |
[[File:LabVIEW Greatest common divisor.png]] |
||
=={{header|LFE}}== |
|||
{{trans|Clojure}} |
|||
<lang lisp> |
|||
> (defun gcd |
|||
"Get the greatest common divisor." |
|||
((a 0) a) |
|||
((a b) (gcd b (rem a b)))) |
|||
</lang> |
|||
Usage: |
|||
<pre> |
|||
> (gcd 12 8) |
|||
4 |
|||
> (gcd 12 -8) |
|||
4 |
|||
> (gcd 96 27) |
|||
3 |
|||
> (gcd 51 34) |
|||
17 |
|||
</pre> |
|||
=={{header|Liberty BASIC}}== |
=={{header|Liberty BASIC}}== |
||
<lang lb>'iterative Euclid algorithm |
<lang lb>'iterative Euclid algorithm |