title: Write One Line C Function To Find Whether A No Is Power Of Two
signature: func writeOneLineCFunctionToFindWhetherANoIsPowerOfTwo(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(2, true)
      fmt.Printf("TEST-1...%s\n", result)
      
      result = driver(8, true)
      fmt.Printf("TEST-2...%s\n", result)
      
      result = driver(1024, true)
      fmt.Printf("TEST-3...%s\n", result)
      
      result = driver(24, false)
      fmt.Printf("TEST-4...%s\n", result)
      
      result = driver(7, false)
      fmt.Printf("TEST-5...%s\n", result)
      
      result = driver(46, false)
      fmt.Printf("TEST-6...%s\n", result)
      
      result = driver(61, false)
      fmt.Printf("TEST-7...%s\n", result)
      
      result = driver(73, false)
      fmt.Printf("TEST-8...%s\n", result)
      
      result = driver(66, false)
      fmt.Printf("TEST-9...%s\n", result)
      
          
  }
source_py: def write_one_line_c_function_to_find_whether_a_no_is_power_of_two(n):
      if (n == 0):
          return False
      while (n != 1):
          if ((n % 2) != 0):
              return False
          n = (n // 2)
      return True
source_cpp: bool write_one_line_c_function_to_find_whether_a_no_is_power_of_two(int n) {
    if ( n == 0 ) return 0;
    while ( n != 1 ) {
      if ( n % 2 != 0 ) return 0;
      n = n / 2;
    }
    return 1;
  }