-
-
Notifications
You must be signed in to change notification settings - Fork 358
Expand file tree
/
Copy patheuclidean.jl
More file actions
36 lines (27 loc) · 603 Bytes
/
euclidean.jl
File metadata and controls
36 lines (27 loc) · 603 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
function euclid_mod(a::Int64, b::Int64)
a = abs(a)
b = abs(b)
while(b != 0)
b,a = a%b,b
end
return a
end
function euclid_sub(a::Int64, b::Int64)
a = abs(a)
b = abs(b)
while (a != b)
if (a > b)
a -= b
else
b -= a
end
end
return a
end
function main()
check1 = euclid_mod(64 * 67, 64 * 81);
check2 = euclid_sub(128 * 12, 128 * 77);
println("[#]\nModulus-based euclidean algorithm result:\n$(check1)")
println("[#]\nSubtraction-based euclidean algorithm result:\n$(check2)")
end
main()