b=1放在while里和外面导致不同-----数学实验

代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可

@param n long长整型 老师给牛牛的数字

@return int整型

def get_digits(n):

list1 = []

if n:

list1 = get_digits(n // 10)

return list1 + list(str(n % 10))

else:

return list1

————————————————

class Solution:
def mathexp(self , n ):
# write code here
a=n
while a>=10:
s=list(map(int,str(a)))
l=len(s)
b=1
for i in range(l):
b =b*s[i]
a=b
return a

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务