title: Steins Algorithm For Finding Gcd 1
signature: function steins_algorithm_for_finding_gcd_1(a, b)
test_code: using Printf
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  function validate_solution(actual, expected)
      return actual == expected
  end
  
  function driver(a, b, expected)
      try
  
          if validate_solution(PLACEHOLDER_FN_NAME(a, b), expected)
              return "PASSED";
          end
          return "FAILED";
      catch exception_obj
          return string(Base.typename(typeof(exception_obj)).wrapper);
      end
  end
  
  function main()
      
      result = driver(52, 29, 1);
      @printf("TEST-0...%s\n",result);
      
      result = driver(36, 94, 2);
      @printf("TEST-1...%s\n",result);
      
      result = driver(12, 6, 6);
      @printf("TEST-2...%s\n",result);
      
      result = driver(69, 7, 1);
      @printf("TEST-3...%s\n",result);
      
      result = driver(45, 11, 1);
      @printf("TEST-4...%s\n",result);
      
      result = driver(7, 51, 1);
      @printf("TEST-5...%s\n",result);
      
      result = driver(45, 55, 5);
      @printf("TEST-6...%s\n",result);
      
      result = driver(62, 86, 2);
      @printf("TEST-7...%s\n",result);
      
      result = driver(96, 63, 3);
      @printf("TEST-8...%s\n",result);
      
      result = driver(89, 12, 1);
      @printf("TEST-9...%s\n",result);
      
  end
  
  main()
source_py: def steins_algorithm_for_finding_gcd_1(a, b):
      if (a == b):
          return a
      if (a == 0):
          return b
      if (b == 0):
          return a
      if (((~ a) & 1) == 1):
          if ((b & 1) == 1):
              return steins_algorithm_for_finding_gcd_1((a >> 1), b)
          else:
              return (steins_algorithm_for_finding_gcd_1((a >> 1), (b >> 1)) << 1)
      if (((~ b) & 1) == 1):
          return steins_algorithm_for_finding_gcd_1(a, (b >> 1))
      if (a > b):
          return steins_algorithm_for_finding_gcd_1(((a - b) >> 1), b)
      return steins_algorithm_for_finding_gcd_1(((b - a) >> 1), a)
source_cpp: int steins_algorithm_for_finding_gcd_1(int a, int b) {
    if ( a == b ) return a;
    if ( a == 0 ) return b;
    if ( b == 0 ) return a;
    if ( ~ a & 1 ) {
      if ( b & 1 ) return steins_algorithm_for_finding_gcd_1 ( a >> 1, b );
      else return steins_algorithm_for_finding_gcd_1 ( a >> 1, b >> 1 ) << 1;
    }
    if ( ~ b & 1 ) return steins_algorithm_for_finding_gcd_1 ( a, b >> 1 );
    if ( a > b ) return steins_algorithm_for_finding_gcd_1 ( ( a - b ) >> 1, b );
    return steins_algorithm_for_finding_gcd_1 ( ( b - a ) >> 1, a );
  }