파이썬
def solution(n, k):
answer = 0
numbers = convert(n, k)
primeNumbers = numbers.split("0")
primeNumbers = list(filter(None, primeNumbers))
primeNumbers = list(map(int, primeNumbers))
for num in primeNumbers:
if num <= 1:
continue
checkPrime = True
squareNum = num**(1/2)
for i in range(2, int(squareNum)+1):
if num % i == 0:
checkPrime = False
if checkPrime:
answer +=1
return answer
def convert(n, k):
converted_num = []
while n > 0:
converted_num.append((str)(n%k))
n //= k
converted_num.reverse()
return "".join(converted_num)
print(solution(110011, 10))