Website Summary Files Commits Branches @commit @diff @stats
path: root / Sem. 03 / GCD_solution2.cpp
blob: ba06c89d1ceb5e72ce7a34d277c10a4a16b5673b (plain) (blame)
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
#include <iostream>

using namespace std;

int main()
{
	int n, k;

	cin >> n >> k;

	if (n < k) //swap
	{
		int temp = n;
		n = k;
		k = temp;
		
	}
	int devider = k;
	bool foundSolution = false;


	while (!foundSolution)
	{
		if (n % devider == 0 && k % devider == 0)
			foundSolution = true;
		else
			devider--;
		
		
	}
	cout << devider;

	

}