comparison maths/MathUtilities.cpp @ 125:5351b5e9ad9f

Add gcd
author Chris Cannam
date Tue, 08 Oct 2013 17:23:17 +0100
parents a37635bbb2c1
children 0fdbb93e92b7
comparison
equal deleted inserted replaced
124:263181813eec 125:5351b5e9ad9f
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