COMP2113
COMP2113_ENGG1340 Programming technologies and Computer programming II [Section 2BC] [2023]
Loading...
Searching...
No Matches
gcd.cpp
Go to the documentation of this file.
1
// gcd.cpp
2
#include <iostream>
3
#include "
gcd.h
"
4
using namespace
std;
5
6
// for simplicity, we assume both inputs to be positive
7
int
gcd
(
int
a,
int
b) {
8
while
(a != b) {
9
if
(a > b) {
10
a -= b;
11
}
else
{
12
b -= a;
13
}
14
}
15
return
a;
16
}
gcd
int gcd(int a, int b)
Definition
gcd.cpp:7
gcd.h
Module4
gcd.cpp
Generated on Thu Nov 14 2024 10:59:44 for COMP2113 by
1.12.0