fork download
  1. fun gcd(a: Int, b: Int): Int {
  2. if (b == 0) {
  3. return a
  4. }
  5.  
  6. return gcd(b, a % b)
  7. }
  8.  
  9. fun main() {
  10. val a = 32
  11. val b = 12
  12.  
  13. val result = gcd(a, b)
  14.  
  15. println("GCD($a, $b) = $result")
  16. }
Success #stdin #stdout 0.07s 36292KB
stdin
Standard input is empty
stdout
GCD(32, 12) = 4