title: Check Number Power K Using Base Changing Method
signature: check_number_power_k_using_base_changing_method <- function(n, k) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(n, k, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(n, k), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          64L, 4L, 
          TRUE
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          16L, 2L, 
          TRUE
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          27L, 3L, 
          TRUE
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          81L, 72L, 
          FALSE
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          1L, 9L, 
          TRUE
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          69L, 17L, 
          FALSE
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          8L, 20L, 
          FALSE
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          31L, 79L, 
          FALSE
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          43L, 81L, 
          FALSE
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          54L, 89L, 
          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;
  }