From 60a886d9b8b7a398a4109be250121fb229aa8e78 Mon Sep 17 00:00:00 2001 From: smalam119 Date: Fri, 20 Apr 2018 01:41:36 +0600 Subject: [PATCH] gcd added --- ProblemSolving/GCD.swift | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 ProblemSolving/GCD.swift diff --git a/ProblemSolving/GCD.swift b/ProblemSolving/GCD.swift new file mode 100644 index 0000000..077056b --- /dev/null +++ b/ProblemSolving/GCD.swift @@ -0,0 +1,13 @@ +//Sayed Mahmudul Alam +//Greatest Common Divisor + +struct GCD { + func getGCD(a: Int, b: Int) -> Int { + let r = a % b + if r != 0 { + return getGCD(a: b, b: r) + } else { + return b + } + } +} \ No newline at end of file