GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Java/Others/GCD.java at master · rpendrick/Java Expand file tree/ Copy pathGCD.javaMore file actions 30 lines (25 loc) · 778 Bytes / Copy pathGCD.javaFile metadata and controls30 lines (25 loc) · 778 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 //Oskar Enmalm 3/10/17 //This is Euclid's algorithm which is used to find the greatest common denominator //Overide function name gcd public class GCD{ public static int gcd(int num1, int num2) { int gcdValue = num1 % num2; while (gcdValue != 0) { num2 = gcdValue; gcdValue = num2 % gcdValue; } return num2; } public static int gcd(int[] number) { int result = number[0]; for(int i = 1; i < number.length; i++) //call gcd function (input two value) result = gcd(result, number[i]); return result; } public static void main(String[] args) { int[] myIntArray = {4,16,32}; //call gcd function (input array) System.out.println(gcd(myIntArray)); } } |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |