|
楼主 |
发表于 2008-2-17 16:41:12
|
显示全部楼层
这个程序可以算出结果
function JC(n)
n=1000;
A=1;
q=1;
for i=1:1:n
tmp=i;
p=0;
z=0;
while tmp>0
p=p+1;
B(p)=tmp-fix(tmp/10)*10;
tmp=fix(tmp/10);
end
bb=zeros(1,p);
for ii=1:1:p
bb(p+1-ii)=B(ii);
end
for jj=1:1:p
B(jj)=bb(jj);
end
H=zeros(p,p+q-1);
for a=1:1:p
for b=1:1:q
H(a,a+b-1)=B(a).*A(b);
end
end
D=zeros(1,p+q-1);
for c=1:1:p+q-1
for d=1:1:p
D(c)=D(c)+H(d,c);
end
end
E(p+q-1)=D(p+q-1);
for w=p+q-2:-1:1
E(w)=D(w)+fix(E(w+1)/10);
end
A(1)=E(1);
for x=2:1:p+q-1
A(x)=E(x)-fix(E(x)/10)*10;
end
r=length(A)-1;
while A(1)>0
z=z+1;
F(z)=A(1)-fix(A(1)/10)*10;
A(1)=fix(A(1)/10);
end
G=zeros(1,z+r);
for y=z+1:1:z+r
G(y)=A(y-z+1);
end
for v=1:1:z
G(v)=F(z-v+1);
end
for s=1:1:z+r
A(s)=G(s);
end
q=z+r;
end
d=0;
for i=q:-1:1
if A(i)==0
d=d+1;
else
break;
end
end
A
q
d(其中开始的n可以为任意用来计算任意位阶乘,A是结果,q是结果的位数,d是最后有多少位零) |
|