-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathone.cpp
62 lines (52 loc) · 1.13 KB
/
one.cpp
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// #include<iostream>
// using namespace std;
// int main(){
// // string name;
// // cout<<"enter the name: ";
// // cin>>name;
// // cout<<"the name is : "<<name;
// string sentance;
// cout<<"enter data: ";
// getline(cin,sentance,'\n');
// cout<<sentance;
// }
#include <iostream>
using namespace std;
// int factorial(int n)
// {
// if (n == 0 || n == 1)
// return 1;
// return n * factorial(n - 1);
// }
// int fibo(int n)
// {
// if (n <= 1)
// {
// return n;
// }
// return fibo(n - 1) + fibo(n - 2);
// }
int gcd(int n1, int n2)
{
if (n2 == 0)
{
return n1;
}
return gcd(n2, n1 % n2);
}
int main()
{
// cout << "hello world!" << endl;
int num1, num2, ans;
// numbers from 1 to n;
cout << "enter number1: " << endl;
cin >> num1;
cout << "enter number2: " << endl;
cin >> num2;
// ans = factorial(num);
// cout << "The factorial of " << num << " is: " << ans;
// ans = fibo(num);
// cout << "The ans:" << " " << ans << endl;
ans = gcd(num1, num2);
cout << "the Gcd is : " << ans << endl;
}