Greatest common divisor: Difference between revisions

(→‎Tests: Rust 0.8 printing)
Line 1,274:
 
=={{header|Julia}}==
Julia includes a built-in <code>gcd</code> function:
Built-in gcd: definition taken from Base
<pre>julia> gcd(4,12)
julia> gcd(6,12)
julia> gcd(7,12)
1</pre>
The actual implementation of this function in Julia 0.2's standard library is reproduced here:
<lang julia>function gcd{T<:Integer}(a::T, b::T)
neg = a < 0
Line 1,285 ⟶ 1,292:
neg ? -g : g
end</lang>
(For arbitrary-precision integers, Julia calls a different implementation from the GMP library.)
{{out}}
<pre>julia> gcd(4,12)
julia> gcd(6,12)
julia> gcd(7,12)
1</pre>
 
=={{header|K}}==
Anonymous user