Skip to content

change formatting in euclid alg in nim #466

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions contents/euclidean_algorithm/code/nim/euclid_algorithm.nim
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
proc euclid_mod(in1, in2: int): int =
var
a = abs(in1)
b = abs(in2)
var
a = abs(in1)
b = abs(in2)

while b != 0:
var temp: int = b
b = a mod b
a = temp;
while b != 0:
let temp: int = b
b = a mod b
a = temp;

return a

proc euclid_sub(in1, in2: int): int =
var
a = abs(in1)
b = abs(in2)
var
a = abs(in1)
b = abs(in2)

while a != b:
if a > b:
a -= b
else:
b -= a
while a != b:
if a > b:
a -= b
else:
b -= a

return a

echo euclid_sub(32*5,32*3)
echo euclid_mod(64*2,64*7)
echo euclid_sub(32*5, 32*3)
echo euclid_mod(64*2, 64*7)