GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — JavaProgramming/BasicJavaProblems/gcd.java at main · pradeepkumar24rk/JavaProgramming

Expand file tree

/

gcd.java

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
36 lines (31 loc) · 929 Bytes
/

gcd.java

Copy path

File metadata and controls

36 lines (31 loc) · 929 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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.