Least common multiple: Difference between revisions
Content added Content deleted
(Added Uiua solution) |
(PascalABC.NET) |
||
Line 2,288: | Line 2,288: | ||
Output: |
Output: |
||
<pre>The least common multiple of 12 and 18 is: 36 |
<pre>The least common multiple of 12 and 18 is: 36 |
||
</pre> |
|||
=={{header|PascalABC.NET}}== |
|||
<syntaxhighlight lang="delphi"> |
|||
function GCD(a,b: integer): integer; |
|||
begin |
|||
while b > 0 do |
|||
(a,b) := (b,a mod b); |
|||
Result := a; |
|||
end; |
|||
function LCM(a,b: integer): integer := a = 0 ? 0 : a div GCD(a,b) * b; |
|||
begin |
|||
Println(LCM(12,18)); |
|||
end. |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
36 |
|||
</pre> |
</pre> |
||