title: Count Set Bits In An Integer 3
signature: count_set_bits_in_an_integer_3 <- function(n) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(n, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(n), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          6L, 
          2L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          58L, 
          4L
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          90L, 
          4L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          69L, 
          3L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          15L, 
          4L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          54L, 
          4L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          60L, 
          4L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          51L, 
          4L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          46L, 
          4L
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          91L, 
          5L
      )))
  
  }
  
  main()
source_py: def count_set_bits_in_an_integer_3(n):
      if (n == 0):
          return 0
      else:
          return (1 + count_set_bits_in_an_integer_3((n & (n - 1))))
source_cpp: int count_set_bits_in_an_integer_3(int n) {
    if ( n == 0 ) return 0;
    else return 1 + count_set_bits_in_an_integer_3 ( n & ( n - 1 ) );
  }