FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JavaProgramming/Function/GreatestCommonDivisor.java at main · Sbiswas001/JavaProgramming · GitHub
Sbiswas001
/
JavaProgramming
Public
forked from
karterhhgg/JavaProgramming
Notifications
You must be signed in to change notification settings
Fork
1
Star
0
Code
Pull requests
1
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
JavaProgramming
/
Function
/
GreatestCommonDivisor.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
24 lines (18 loc) · 517 Bytes
Breadcrumbs
JavaProgramming
/
Function
/
GreatestCommonDivisor.java
Copy path
File metadata and controls
24 lines (18 loc) · 517 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
//Write a function that calculates the Greatest Common Divisor of 2 numbers.
package
Function
;
import
java
.
util
.
Scanner
;
public
class
GreatestCommonDivisor
{
public
static
void
main
(
String
args
[]) {
Scanner
sc
=
new
Scanner
(
System
.
in
);
int
n1
=
sc
.
nextInt
();
int
n2
=
sc
.
nextInt
();
while
(
n1
!=
n2
) {
if
(
n1
>
n2
) {
n1
=
n1
-
n2
;
}
else
{
n2
=
n2
-
n1
;
}
}
System
.
out
.
println
(
"GCD is : "
+
n2
);
}
}
Back
|
FazBrowse Home
|
New Git URL