FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cpp-programming/OOP1-Lab7/gcd.cpp at main · Exzqqq/cpp-programming · GitHub
Exzqqq
/
cpp-programming
Public
forked from
Rustam-Z/cpp-programming
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cpp-programming
/
OOP1-Lab7
/
gcd.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
20 lines (20 loc) · 716 Bytes
Breadcrumbs
cpp-programming
/
OOP1-Lab7
/
gcd.cpp
Copy path
File metadata and controls
20 lines (20 loc) · 716 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
#
include
<
iostream
>
using
namespace
std
;
int
gcd
(
int
x,
int
y) {
if
(x ==
0
|| y==
0
)
return
y,x;
//
will input non-zero number when even one number inputed in zero
if
(x == y)
return
x;
//
will return first number when both of the numbers are equal
if
(x > y)
return
gcd
(x - y, y);
//
when first number is greater than second
if
( y > x )
return
gcd
(x, y - x);
//
when second number is greater than first
}
int
main4
() {
cout <<
"
\t\t\t
***Program to calculate the G.C.D for two integers usin recurion.***
"
<< endl;
cout <<
"
Please enter two integers:
"
<< endl;
int
x,y;
cin >> x >> y;
cout <<
"
The G.C.D of
"
<< x <<
"
and
"
<< y <<
"
is
"
<<
gcd
(x, y);
//
calling function in the main function
return
0
;
}
Back
|
FazBrowse Home
|
New Git URL