h*z
2 楼
//Java
public class Solution {
public int trailingZeroes(int n) {
int ret = 0;
for(long i=5;n/i>=1;i*=5)
ret +=n/i;
return ret;
}
}
有问题么?
public class Solution {
public int trailingZeroes(int n) {
int ret = 0;
for(long i=5;n/i>=1;i*=5)
ret +=n/i;
return ret;
}
}
有问题么?
g*t
4 楼
// Python
算法看了下攻略,自己实现一个
class Solution:
# @return an integer
def trailingZeroes(self, n):
# the number of zeroes depends on the pair of '2' * '5' . Obviously,
2 is more than 5 in n!. just count how many 5 are multiplied in factorial.
if n <= 0 : return 0
res = 0
size = 0
while n != 0:
size = n / 5
res += size
n = size
return res
算法看了下攻略,自己实现一个
class Solution:
# @return an integer
def trailingZeroes(self, n):
# the number of zeroes depends on the pair of '2' * '5' . Obviously,
2 is more than 5 in n!. just count how many 5 are multiplied in factorial.
if n <= 0 : return 0
res = 0
size = 0
while n != 0:
size = n / 5
res += size
n = size
return res
z*c
8 楼
public int trailingZeroes(int n) {
int count = 0;
while (n > 0) {
count += n/5;
n /= 5;
}
return count;
}
int count = 0;
while (n > 0) {
count += n/5;
n /= 5;
}
return count;
}
相关阅读
如果OPT启动时间到了,卡还没寄过来,能不能入职?也问个opt的问题现在准备cs面试有哪些网站?职位要求问个经典面试题求助!!Sam's Club临时取消我的intern offer怎么办question about google's offer做OLED的想进工业界求推荐多选一的onsite面试,面试的先后顺序有讲究吗?h1b approve后,10月1日前,是不是最好不出境?opt extension多久可以收到收据请教大家Contract的工作的利弊问个google面试题大家发出简历后多久能有回音?问两道google面试题谁能给个hashset实现的例子么?senior bookkeeper能否办H1有人了解Loop interview吗?问个奇怪的事急!!!求助!!!为什么USCIS接电话的人说我不满足emergency criteria?