title: Check Number Power K Using Base Changing Method
signature: function checkNumberPowerKUsingBaseChangingMethod($n, $k) {
test_code: <?php
  
  
  // SOLUTION CODE 
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  function validateSolution($actual, $expected){
      return serialize($actual) == serialize($expected);
  }
  
  function driver($n, $k, $expected){
      try{
        if (validateSolution(PLACEHOLDER_FN_NAME($n, $k), $expected)){
          return "PASSED";
        }
        return "FAILED";
      }
      catch (Exception $exception_obj) {
        return get_class($exception_obj);
      }
  }
  
  function main(){
      printf("TEST-0...%s\n",driver(
        64, 4, 
        true));
      
      printf("TEST-1...%s\n",driver(
        16, 2, 
        true));
      
      printf("TEST-2...%s\n",driver(
        27, 3, 
        true));
      
      printf("TEST-3...%s\n",driver(
        81, 72, 
        false));
      
      printf("TEST-4...%s\n",driver(
        1, 9, 
        true));
      
      printf("TEST-5...%s\n",driver(
        69, 17, 
        false));
      
      printf("TEST-6...%s\n",driver(
        8, 20, 
        false));
      
      printf("TEST-7...%s\n",driver(
        31, 79, 
        false));
      
      printf("TEST-8...%s\n",driver(
        43, 81, 
        false));
      
      printf("TEST-9...%s\n",driver(
        54, 89, 
        false));
      
  }
  
  main();
  ?>
source_py: def check_number_power_k_using_base_changing_method(n, k):
      oneSeen = False
      while (n > 0):
          digit = (n % k)
          if (digit > 1):
              return False
          if (digit == 1):
              if oneSeen:
                  return False
              oneSeen = True
          n //= k
      return True
source_cpp: bool check_number_power_k_using_base_changing_method(unsigned int n, unsigned int k) {
    bool oneSeen = false;
    while ( n > 0 ) {
      int digit = n % k;
      if ( digit > 1 ) return false;
      if ( digit == 1 ) {
        if ( oneSeen ) return false;
        oneSeen = true;
      }
      n /= k;
    }
    return true;
  }