首页
题库
面试
求职
学习
竞赛
More+
所有博客
搜索面经/职位/试题/公司
搜索
我要招人
去企业版
登录 / 注册
首页
>
试题广场
>
阶乘末尾0的数量
[编程题]阶乘末尾0的数量
热度指数:12094
时间限制:C/C++ 2秒,其他语言4秒
空间限制:C/C++ 256M,其他语言512M
算法知识视频讲解
给定一个非负整数 n
,返回 n!
结果的末尾为 0
的数量。
n! 是指自然数 n!
的阶乘,即 :
。
特殊的, 0 的阶乘是 1 。
数据范围:
进阶:空间复杂度
,时间复杂度
复杂度要求:
不大于
示例1
输入
3
输出
0
说明
3!=6
示例2
输入
5
输出
1
说明
5!=120
示例3
输入
1000000000
输出
249999998
马上挑战
算法知识视频讲解
提交运行
算法知识视频讲解
添加笔记
求解答(0)
邀请回答
收藏(184)
分享
提交结果有问题?
0个回答
27篇题解
添加回答
这道题你会答吗?花几分钟告诉大家答案吧!
提交观点
问题信息
基础数学
难度:
0条回答
184收藏
5101浏览
热门推荐
通过挑战的用户
查看代码
陆十四
2022-10-11 22:36:57
在记录秋招的茶...
2022-09-16 09:16:54
xxdev
2022-09-15 23:49:09
Tommyle...
2022-09-15 21:36:53
ariou
2022-09-14 22:31:12
相关试题
牛牛的超市
动态规划
基础数学
评论
(5)
车站建造问题
基础数学
评论
(40)
线段树编号问题
基础数学
评论
(2)
小刘去服装店购买了一批衣服,他先给...
数学运算
评论
(3)
在一个 Spring Boot 应...
Spring
评论
(1)
阶乘末尾0的数量
扫描二维码,关注牛客网
意见反馈
下载牛客APP,随时随地刷题
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * the number of 0 * @param n long长整型 the number * @return long长整型 */ public long thenumberof0 (long n) { // write code here } }
class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * the number of 0 * @param n long长整型 the number * @return long长整型 */ long long thenumberof0(long long n) { // write code here } };
#coding:utf-8 # # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # the number of 0 # @param n long长整型 the number # @return long长整型 # class Solution: def thenumberof0(self , n ): # write code here
using System; using System.Collections.Generic; class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * the number of 0 * @param n long长整型 the number * @return long长整型 */ public long thenumberof0 (long n) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * the number of 0 * @param n long长整型 the number * @return long长整型 */ function thenumberof0( n ) { // write code here } module.exports = { thenumberof0 : thenumberof0 };
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # the number of 0 # @param n long长整型 the number # @return long长整型 # class Solution: def thenumberof0(self , n: int) -> int: # write code here
package main import "fmt" /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * the number of 0 * @param n long长整型 the number * @return long长整型 */ func thenumberof0( n int64 ) int64 { // write code here }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * the number of 0 * @param n long长整型 the number * @return long长整型 */ long long thenumberof0(long long n ) { // write code here }
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # the number of 0 # @param n long长整型 the number # @return long长整型 # class Solution def thenumberof0(n) # write code here end end
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * the number of 0 * @param n long长整型 the number * @return long长整型 */ def thenumberof0(n: Long): Long = { // write code here } }
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * the number of 0 * @param n long长整型 the number * @return long长整型 */ fun thenumberof0(n: Long): Long { // write code here } }
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * the number of 0 * @param n long长整型 the number * @return long长整型 */ public long thenumberof0 (long n) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * the number of 0 * @param n long长整型 the number * @return long长整型 */ export function thenumberof0(n: number): number { // write code here }
public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * the number of 0 * @param n long长整型 the number * @return long长整型 */ func thenumberof0 ( _ n: Int64) -> Int64 { // write code here } }
struct Solution{ } impl Solution { fn new() -> Self { Solution{} } /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * the number of 0 * @param n long长整型 the number * @return long长整型 */ pub fn thenumberof0(&self, n: i64) -> i64 { // write code here } }
3
0
5
1
1000000000
249999998