From a7ce590a0711150d21f94f5c3f7e7348324a8dec Mon Sep 17 00:00:00 2001 From: Li Yu Date: Sun, 1 May 2022 19:04:17 +0800 Subject: [PATCH] added gcd.hhs --- gcd.hhs | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 gcd.hhs diff --git a/gcd.hhs b/gcd.hhs new file mode 100644 index 0000000..44db42e --- /dev/null +++ b/gcd.hhs @@ -0,0 +1,12 @@ +/** + * @author Yu Li + * @param a, b - integers + * @returns - gcd of a, b + * find the greatest common divisor of a, b + */ +function gcd(a, b) { + if (b == 0) { + return a; + } + return gcd(b, a % b); +} \ No newline at end of file