From 3bd769d2ae947299d09b77170c2f8f6fffbe9966 Mon Sep 17 00:00:00 2001 From: teerapat1739 Date: Sat, 28 Oct 2017 01:19:55 +0700 Subject: [PATCH] Increase recursive GCD --- Others/GCD.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Others/GCD.java b/Others/GCD.java index dba60c68..94f443b0 100644 --- a/Others/GCD.java +++ b/Others/GCD.java @@ -13,3 +13,12 @@ public static int gcd(int a, int b) { return b; } } + +//Increase the number of calculations. +//Use functoin from above as recursive. +public static int gcd(int[] number) { + int result = number[0]; + for(int i = 1; i < number.length; i++) + result = gcd(result, number[i]); + return result; +}