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 — JavaProgramming/BasicJavaProblems/gcd.java at main · pradeepkumar24rk/JavaProgramming Expand file tree/ Copy pathgcd.javaMore file actions 36 lines (31 loc) · 929 Bytes / Copy pathgcd.javaFile metadata and controls36 lines (31 loc) · 929 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 31 32 33 34 35 36 package BasicJavaProblems; public class gcd { static int GeneralMethod(int a, int b) { int gcd = 0; for (int i = 1; i <= a && i <= b; i++) { if (a % i == 0 && b % i == 0) gcd = i; } return gcd; } static int eludienSub(int a, int b) { if (b == 0) return a; else return eludienSub(b, Math.abs(a - b)); } static int eludienMod(int a, int b) { if (b == 0) return a; else return eludienSub(b, (a % b)); } public static void main(String[] args) { System.out.println("General Method :"); System.out.println(GeneralMethod(20, 30)); System.out.println("Eudien Algorithm(Subtraction)"); System.out.println(eludienSub(20, 30)); System.out.println("Eudien Algorithm(%)"); System.out.println(eludienMod(20, 30)); } } |
| You are visitor 01402503 — 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. |