title: Check If A Number Is Power Of Another Number
signature: func checkIfANumberIsPowerOfAnotherNumber(x int, y 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(x int, y int, expected bool) string {
      if validateSolution(PLACEHOLDER_FN_NAME(x, y),expected) {
              return "PASSED"
      }
      return "FAILED"
  
  }
  
  func main() {
  
      // Use imports to avoid undefined errors
      var _ = reflect.DeepEqual
      _ = math.Abs
      _ = sort.Sort
      result := ""
      result = driver(57, 
  	1, true)
      fmt.Printf("TEST-0...%s\n", result)
      
      result = driver(3, 
  	9, true)
      fmt.Printf("TEST-1...%s\n", result)
      
      result = driver(10, 
  	101, false)
      fmt.Printf("TEST-2...%s\n", result)
      
      result = driver(10, 
  	10000, true)
      fmt.Printf("TEST-3...%s\n", result)
      
      result = driver(6, 
  	46656, true)
      fmt.Printf("TEST-4...%s\n", result)
      
      result = driver(2, 
  	2048, true)
      fmt.Printf("TEST-5...%s\n", result)
      
      result = driver(1, 
  	40, false)
      fmt.Printf("TEST-6...%s\n", result)
      
      result = driver(20, 
  	79, false)
      fmt.Printf("TEST-7...%s\n", result)
      
      result = driver(96, 
  	98, false)
      fmt.Printf("TEST-8...%s\n", result)
      
      result = driver(25, 
  	5, false)
      fmt.Printf("TEST-9...%s\n", result)
      
          
  }
source_py: def check_if_a_number_is_power_of_another_number(x, y):
      if (x == 1):
          return (y == 1)
      pow = 1
      while (pow < y):
          pow = (pow * x)
      return (pow == y)
source_cpp: bool check_if_a_number_is_power_of_another_number(int x, long int y) {
    if ( x == 1 ) return ( y == 1 );
    long int pow = 1;
    while ( pow < y ) pow *= x;
    return ( pow == y );
  }