diff options
| author | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
|---|---|---|
| committer | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
| commit | 33613a85afc4b1481367fbe92a17ee59c240250b (patch) | |
| tree | 670b842326116b376b505ec2263878912fca97e2 /Bachelor/Prog1/Prakt3/prg1p3_4/main.cpp | |
| download | Studium-master.tar.gz Studium-master.tar.bz2 | |
Diffstat (limited to 'Bachelor/Prog1/Prakt3/prg1p3_4/main.cpp')
| -rw-r--r-- | Bachelor/Prog1/Prakt3/prg1p3_4/main.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/Bachelor/Prog1/Prakt3/prg1p3_4/main.cpp b/Bachelor/Prog1/Prakt3/prg1p3_4/main.cpp new file mode 100644 index 0000000..d66c34c --- /dev/null +++ b/Bachelor/Prog1/Prakt3/prg1p3_4/main.cpp @@ -0,0 +1,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);
+ }
+}
\ No newline at end of file |
