Greater Common Divisor (GCD), the Euclidean way
GDC using the Euclidean algorithm and different programming languages (as a means of a very simple coding kata):
Python (http://ideone.com/jqCLR):
1 | def gcd(num,den): |
C
1 | #include <stdio.h> |
C++
1 | #include <iostream> |
Java (http://ideone.com/nFqLf)
1 | import java.math.*; |
Ruby (http://ideone.com/Q8HPg)
1 | def mcd(a,b) |
<< Home