title: Find Whether A Given Number Is A Power Of 4 Or Not 1
signature: func findWhetherAGivenNumberIsAPowerOf4OrNot1(n int) bool {
test_code: package main
  
  import (
      "fmt"
      "reflect"
      "math"
      "sort"
  )
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  func validateSolution(actual bool, expected bool) bool {
      return reflect.DeepEqual(actual,expected)
  }
  
  func driver(n int, expected bool) string {
      if validateSolution(PLACEHOLDER_FN_NAME(n),expected) {
              return "PASSED"
      }
      return "FAILED"
  
  }
  
  func main() {
  
      // Use imports to avoid undefined errors
      var _ = reflect.DeepEqual
      _ = math.Abs
      _ = sort.Sort
      result := ""
      result = driver(1, true)
      fmt.Printf("TEST-0...%s\n", result)
      
      result = driver(4, true)
      fmt.Printf("TEST-1...%s\n", result)
      
      result = driver(64, true)
      fmt.Printf("TEST-2...%s\n", result)
      
      result = driver(-64, false)
      fmt.Printf("TEST-3...%s\n", result)
      
      result = driver(128, false)
      fmt.Printf("TEST-4...%s\n", result)
      
      result = driver(1024, true)
      fmt.Printf("TEST-5...%s\n", result)
      
      result = driver(45, false)
      fmt.Printf("TEST-6...%s\n", result)
      
      result = driver(33, false)
      fmt.Printf("TEST-7...%s\n", result)
      
      result = driver(66, false)
      fmt.Printf("TEST-8...%s\n", result)
      
      result = driver(74, false)
      fmt.Printf("TEST-9...%s\n", result)
      
          
  }
source_py: def find_whether_a_given_number_is_a_power_of_4_or_not_1(n):
      count = 0
      if (n and (not (n & (n - 1)))):
          while (n > 1):
              n >>= 1
              count += 1
          if ((count % 2) == 0):
              return True
          else:
              return False
source_cpp: bool find_whether_a_given_number_is_a_power_of_4_or_not_1(unsigned int n) {
    int count = 0;
    if ( n && ! ( n & ( n - 1 ) ) ) {
      while ( n > 1 ) {
        n >>= 1;
        count += 1;
      }
      return ( count % 2 == 0 ) ? 1 : 0;
    }
    return 0;
  }