Skip to content

Commit 744dc9a

Browse files
authored
Create GCF.java
1 parent b09111f commit 744dc9a

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Easy/GCF.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import java.util.*;
2+
import java.io.*;
3+
4+
class Main {
5+
6+
public static int GCF(int[] arr) {
7+
// code goes here
8+
int sayac=1,gfc=0;
9+
10+
11+
while ( sayac <= arr[0]){
12+
13+
if ( arr[0] % sayac==0 && arr[1]%sayac==0) gfc=sayac;
14+
15+
sayac++;
16+
}
17+
18+
return gfc==0 ? 1 : gfc;
19+
20+
}
21+
22+
public static void main (String[] args) {
23+
// keep this function call here
24+
Scanner s = new Scanner(System.in);
25+
System.out.print(GCF(s.nextLine()));
26+
}
27+
28+
}

0 commit comments

Comments
 (0)