title: Check Number Power K Using Base Changing Method
signature: def check_number_power_k_using_base_changing_method(n, k):
test_code: import array
  import bisect
  import collections
  import datetime
  import functools
  import heapq
  import itertools
  import math
  import queue
  import re
  import string
  import sys
  from typing import Any, Dict, List, Optional, Set
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  def validate_solution(actual, expected):
      return actual == expected
  
  def driver(n, k, expected):
      try:
          if validate_solution(PLACEHOLDER_FN_NAME(
              n, k),
              expected
          ):
              return "PASSED"
          return "FAILED"
      except Exception as exception_obj:
          return type(exception_obj).__name__
      
  if __name__ == "__main__":
      result = driver(64, 4, True)
      print(f"TEST-0...{result}")
  
      result = driver(16, 2, True)
      print(f"TEST-1...{result}")
  
      result = driver(27, 3, True)
      print(f"TEST-2...{result}")
  
      result = driver(81, 72, False)
      print(f"TEST-3...{result}")
  
      result = driver(1, 9, True)
      print(f"TEST-4...{result}")
  
      result = driver(69, 17, False)
      print(f"TEST-5...{result}")
  
      result = driver(8, 20, False)
      print(f"TEST-6...{result}")
  
      result = driver(31, 79, False)
      print(f"TEST-7...{result}")
  
      result = driver(43, 81, False)
      print(f"TEST-8...{result}")
  
      result = driver(54, 89, False)
      print(f"TEST-9...{result}")
  
      sys.exit(0)
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;
  }