1,35%是一个比例,0.35只是一个值,7/20才存在这样的比较.
2,
1000以内是:192个0
10000以内是:2983个0用以下代码算的.
select top 10000 identity(int,1,1) as N into # from 
(select top 100 id=1  from sysobjects) as a,
(select top 100 id=1  from sysobjects) as b,
(select top 100 id=1  from sysobjects) as cdeclare @i int
set @i=0
select @i=@i+len(cast(n as varchar))-len(replace(cast(n as varchar),'0','')) from # where n<=1000
print @i

解决方案 »

  1.   

    create or replace function get_num
    return number
    as
    num number:=1;
    begin
    for i in 1..1000 loop
    num:=num*i;
    end loop;
    num:=length(num)-instr(num,0)+1;
    return num;
    end;
    /select get_num from dual;  --可惜已超过number最大精度了
      

  2.   

    下面是SQL的代码求解方法:1,建自定义函数:create function Factor(@i int,@type int)
    returns int
    as 
    begin
    declare @V int,@LastI int
    set @LastI=@i
    set @v=0
    while 1=1
    begin 
    if  @LastI%@Type =0
    begin
       set @V=@V+1
    set @LastI=@LastI/@type
    end
    else
    Return @V
    end
      Return @V
    end
    2,计算
    select top 10000 identity(int,1,1) as N into # from 
    (select top 100 id=1  from sysobjects) as a,
    (select top 100 id=1  from sysobjects) as b,
    (select top 100 id=1  from sysobjects) as c
    select dbo.factor(n,2) ,dbo.factor(n,5),N from #select sum(dbo.factor(n,2)) [2的因子数],sum(dbo.factor(n,5)) [5的因子数] from # where n<=1000drop table #--------------
    2的因子数       5的因子数       
    ----------- ----------- 
    994         994
    结论是结尾应该是994个0,而不是249个0.
    这个结果是按我上面所说的理论为基础课的,不知道上面的理论是不是正确,
      

  3.   

    更正一下:select top 1000 identity(int,1,1) as N into # from 
    (select top 100 id=1  from sysobjects) as a,
    (select top 100 id=1  from sysobjects) as b,
    (select top 100 id=1  from sysobjects) as c
    select dbo.factor(n,2) a,dbo.factor(n,5) b,N into #a from #
    Select sum(a) [2的因子数] ,sum(b) [5的因子数] from #adrop table #a
    drop table #
    ----------------------------------------------------------2的因子数       5的因子数       
    ----------- ----------- 
    994         249