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"
4using namespace std;
5
6// for simplicity, we assume both inputs to be positive
7int 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}
int gcd(int a, int b)
Definition gcd.cpp:7