MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB论坛 (https://www.labfans.com/bbs/forumdisplay.php?f=6)
-   -   [求助]n!中末尾0的个数 (https://www.labfans.com/bbs/showthread.php?t=7259)

toddwu 2009-04-01 23:11

[求助]n!中末尾0的个数
 
编写函数文件,参数为整数n,返回值为:n!尾部0的个数。

我编写的是:
n=('please input n=');
s=0;
m=fix(log(n)/log(5));
for t=1:n
for k=1:m
if n/(5.^k)==round(n/(5.^k))
s=s+1;
end
end
end
不知道哪里出错了


所有时间均为北京时间。现在的时间是 13:15

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.