summaryrefslogtreecommitdiffstats
path: root/Bachelor/Prog1/Prakt3/prg1p3_4/main.cpp
blob: d66c34cea375fbf5126c70f7ea26ead527380920 (plain)
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
// Programmieren 1, Praktikum 3, Aufgabe 4
// Sven Eisenhauer
// 17.11.2004
//
// file: main.cpp
//
// purpose: find the greatest common divisor of two numbers, recursive...          
//          
//

#include <iostream>
using std::cin;
using std::cout;
using std::endl;

int gcd(int,int);

int main()
{
	int number1,
		number2;

	cout << "1st number: ";
	cin >> number1;
	cout << "2nd number: ";
	cin >> number2;

	cout <<endl<<"Greatest common divisor: "<< gcd(number1,number2) << endl;

	return 0;
}

int gcd(int x, int y)
{
	if (0 == y)
	{
		return x;
	}
	else
	{
		return gcd (y,x%y);
	}
}