comparison maths/MathUtilities.cpp @ 350:a067c2eeb13c

Add gcd
author Chris Cannam <c.cannam@qmul.ac.uk>
date Tue, 08 Oct 2013 17:23:17 +0100
parents 50fae18236ee
children a694700f71d8
comparison
equal deleted inserted replaced
349:b247af4c23d2 350:a067c2eeb13c
388 f = f * i; 388 f = f * i;
389 } 389 }
390 return f; 390 return f;
391 } 391 }
392 392
393 int
394 MathUtilities::gcd(int a, int b)
395 {
396 int c = a % b;
397 if (c == 0) {
398 return b;
399 } else {
400 return gcd(b, c);
401 }
402 }
403