title: Fast Multiplication Method Without Using Multiplication Operator Russian Peasants Algorithm
signature: func fastMultiplicationMethodWithoutUsingMultiplicationOperatorRussianPeasantsAlgorithm(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(4, 
  	33, 132)
      fmt.Printf("TEST-0...%s\n", result)
      
      result = driver(36, 
  	67, 2412)
      fmt.Printf("TEST-1...%s\n", result)
      
      result = driver(65, 
  	52, 3380)
      fmt.Printf("TEST-2...%s\n", result)
      
      result = driver(55, 
  	37, 2035)
      fmt.Printf("TEST-3...%s\n", result)
      
      result = driver(35, 
  	76, 2660)
      fmt.Printf("TEST-4...%s\n", result)
      
      result = driver(69, 
  	98, 6762)
      fmt.Printf("TEST-5...%s\n", result)
      
      result = driver(84, 
  	62, 5208)
      fmt.Printf("TEST-6...%s\n", result)
      
      result = driver(5, 
  	80, 400)
      fmt.Printf("TEST-7...%s\n", result)
      
      result = driver(15, 
  	36, 540)
      fmt.Printf("TEST-8...%s\n", result)
      
      result = driver(67, 
  	84, 5628)
      fmt.Printf("TEST-9...%s\n", result)
      
          
  }
source_py: def fast_multiplication_method_without_using_multiplication_operator_russian_peasants_algorithm(a, b):
      res = 0
      while (b > 0):
          if (b & 1):
              res = (res + a)
          a = (a << 1)
          b = (b >> 1)
      return res
source_cpp: unsigned int fast_multiplication_method_without_using_multiplication_operator_russian_peasants_algorithm(unsigned int a, unsigned int b) {
    int res = 0;
    while ( b > 0 ) {
      if ( b & 1 ) res = res + a;
      a = a << 1;
      b = b >> 1;
    }
    return res;
  }