title: Check Number Power K Using Base Changing Method
signature: function checkNumberPowerKUsingBaseChangingMethod(n: number, k: number): boolean {
test_code: 
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  function convertToString(value: any): string{
      return JSON.stringify(value, function (key, val) {
          if (val instanceof Set) {
              return Array.from(val);
          } return val;});
  }
  
  function validateSolution(actual: boolean, expected: boolean): boolean {
      return convertToString(actual) === convertToString(expected);
  }
  
  function driver(n: number, k: number, expected:boolean): string {
      try{
          if (validateSolution(PLACEHOLDER_FN_NAME(n, k),expected)){
              return "PASSED";
          }
          return "FAILED";
      } catch (error) {
        return error.name;
      }
      
  }
      
  function main(){
    let result = '';
    result = driver(64, 4, true);
    console.log(`TEST-0...${result}`);
  
    result = driver(16, 2, true);
    console.log(`TEST-1...${result}`);
  
    result = driver(27, 3, true);
    console.log(`TEST-2...${result}`);
  
    result = driver(81, 72, false);
    console.log(`TEST-3...${result}`);
  
    result = driver(1, 9, true);
    console.log(`TEST-4...${result}`);
  
    result = driver(69, 17, false);
    console.log(`TEST-5...${result}`);
  
    result = driver(8, 20, false);
    console.log(`TEST-6...${result}`);
  
    result = driver(31, 79, false);
    console.log(`TEST-7...${result}`);
  
    result = driver(43, 81, false);
    console.log(`TEST-8...${result}`);
  
    result = driver(54, 89, false);
    console.log(`TEST-9...${result}`);
  
  };
  
  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;
  }