From edde956625de87c6426796d87364c30808cf8a27 Mon Sep 17 00:00:00 2001 From: Oskar Enmalm Date: Tue, 3 Oct 2017 10:02:42 +0200 Subject: [PATCH] Create GCD.java --- Misc/GCD.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Misc/GCD.java diff --git a/Misc/GCD.java b/Misc/GCD.java new file mode 100644 index 00000000..dba60c68 --- /dev/null +++ b/Misc/GCD.java @@ -0,0 +1,15 @@ +//Oskar Enmalm 3/10/17 +//This is Euclid's algorithm which is used to find the greatest common denominator + +public class GCD{ + +public static int gcd(int a, int b) { + + int r = a % b; + while (r != 0) { + b = r; + r = b % r; + } + return b; + } +}