1 题目描述
2 解题思路
进制转换的同时,对每一位进行加法运算
class Solution:
def sumBase(self, n: int, k: int) -> int:
ret=0
while(n>0):
ret+=n%k
n=n//k
return(ret)
进制转换的同时,对每一位进行加法运算
class Solution:
def sumBase(self, n: int, k: int) -> int:
ret=0
while(n>0):
ret+=n%k
n=n//k
return(ret)