title: Steins Algorithm For Finding Gcd 1
signature: function steinsAlgorithmForFindingGcd1($a, $b) {
test_code: <?php
  
  
  // SOLUTION CODE 
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  function validateSolution($actual, $expected){
      return serialize($actual) == serialize($expected);
  }
  
  function driver($a, $b, $expected){
      try{
        if (validateSolution(PLACEHOLDER_FN_NAME($a, $b), $expected)){
          return "PASSED";
        }
        return "FAILED";
      }
      catch (Exception $exception_obj) {
        return get_class($exception_obj);
      }
  }
  
  function main(){
      printf("TEST-0...%s\n",driver(
        52, 29, 
        1));
      
      printf("TEST-1...%s\n",driver(
        36, 94, 
        2));
      
      printf("TEST-2...%s\n",driver(
        12, 6, 
        6));
      
      printf("TEST-3...%s\n",driver(
        69, 7, 
        1));
      
      printf("TEST-4...%s\n",driver(
        45, 11, 
        1));
      
      printf("TEST-5...%s\n",driver(
        7, 51, 
        1));
      
      printf("TEST-6...%s\n",driver(
        45, 55, 
        5));
      
      printf("TEST-7...%s\n",driver(
        62, 86, 
        2));
      
      printf("TEST-8...%s\n",driver(
        96, 63, 
        3));
      
      printf("TEST-9...%s\n",driver(
        89, 12, 
        1));
      
  }
  
  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 );
  }