title: Check Number Power K Using Base Changing Method
signature: fun checkNumberPowerKUsingBaseChangingMethod(n: Int, k: Int): Boolean {
test_code: package main
  
  import kotlin.text.*
  import kotlin.math.*
  
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  fun validateSolution(actual:Boolean, expected:Boolean):Boolean{
    return actual.equals(expected)
  }
  fun driver(n: Int, k: Int, expected:Boolean):String {
      try{
        if (validateSolution(PLACEHOLDER_FN_NAME(n, k), expected)) {
                return "PASSED"
        }
        return "FAILED"
      } catch (e: Exception){
        return e::class.simpleName as String
      }
  
  }
  
  fun main() {
      var result: String = ""
      result = driver(64, 4, true)
      println("TEST-0...${result}")
      
      result = driver(16, 2, true)
      println("TEST-1...${result}")
      
      result = driver(27, 3, true)
      println("TEST-2...${result}")
      
      result = driver(81, 72, false)
      println("TEST-3...${result}")
      
      result = driver(1, 9, true)
      println("TEST-4...${result}")
      
      result = driver(69, 17, false)
      println("TEST-5...${result}")
      
      result = driver(8, 20, false)
      println("TEST-6...${result}")
      
      result = driver(31, 79, false)
      println("TEST-7...${result}")
      
      result = driver(43, 81, false)
      println("TEST-8...${result}")
      
      result = driver(54, 89, false)
      println("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;
  }