diff --git a/dana/programs/gcd.dana b/dana/programs/gcd.dana new file mode 100644 index 0000000..c231e6a --- /dev/null +++ b/dana/programs/gcd.dana @@ -0,0 +1,26 @@ +def main + + def gcd is int: a b as int + if b == 0: return: a + else: + begin + var s is int + s := gcd: b, a % b + return: s + end + + var n1 n2 is int + (* just messing around *) var d is int + + writeString: "Give me two positive integers: \n" + n1 := readInteger() + n2 := readInteger() + + # Making sure numbers are non-negative + + if n1 < 0: n1 := -n1 + if not n2 >= 0: n2 := -n2 + d := gcd(n1, n2) + writeString: "\nTheir GCD is: " + writeInteger: d + writeString: "\n" \ No newline at end of file diff --git a/dana/programs/gcd.input b/dana/programs/gcd.input new file mode 100644 index 0000000..9318f84 --- /dev/null +++ b/dana/programs/gcd.input @@ -0,0 +1 @@ +../../alan/programs/gcd.input \ No newline at end of file diff --git a/dana/programs/gcd.result b/dana/programs/gcd.result new file mode 100644 index 0000000..a163c39 --- /dev/null +++ b/dana/programs/gcd.result @@ -0,0 +1 @@ +../../alan/programs/gcd.result \ No newline at end of file