title: Basic And Extended Euclidean Algorithms
signature: func basicAndExtendedEuclideanAlgorithms(a int, b int) int {
test_code: package main
  
  import (
      "fmt"
      "reflect"
      "math"
      "sort"
  )
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  func validateSolution(actual int, expected int) bool {
      return reflect.DeepEqual(actual,expected)
  }
  
  func driver(a int, b int, expected int) string {
      if validateSolution(PLACEHOLDER_FN_NAME(a, b),expected) {
              return "PASSED"
      }
      return "FAILED"
  
  }
  
  func main() {
  
      // Use imports to avoid undefined errors
      var _ = reflect.DeepEqual
      _ = math.Abs
      _ = sort.Sort
      result := ""
      result = driver(46, 
  	89, 1)
      fmt.Printf("TEST-0...%s\n", result)
      
      result = driver(26, 
  	82, 2)
      fmt.Printf("TEST-1...%s\n", result)
      
      result = driver(40, 
  	12, 4)
      fmt.Printf("TEST-2...%s\n", result)
      
      result = driver(58, 
  	4, 2)
      fmt.Printf("TEST-3...%s\n", result)
      
      result = driver(25, 
  	44, 1)
      fmt.Printf("TEST-4...%s\n", result)
      
      result = driver(2, 
  	87, 1)
      fmt.Printf("TEST-5...%s\n", result)
      
      result = driver(8, 
  	65, 1)
      fmt.Printf("TEST-6...%s\n", result)
      
      result = driver(21, 
  	87, 3)
      fmt.Printf("TEST-7...%s\n", result)
      
      result = driver(82, 
  	10, 2)
      fmt.Printf("TEST-8...%s\n", result)
      
      result = driver(17, 
  	61, 1)
      fmt.Printf("TEST-9...%s\n", result)
      
          
  }
source_py: def basic_and_extended_euclidean_algorithms(a, b):
      if (a == 0):
          return b
      return basic_and_extended_euclidean_algorithms((b % a), a)
source_cpp: int basic_and_extended_euclidean_algorithms(int a, int b) {
    if ( a == 0 ) return b;
    return basic_and_extended_euclidean_algorithms ( b % a, a );
  }