Just a note
目的:计算n!的位数。若先计算n!再依次除以10,则当n的值很大时,会溢出。所以可以通过数学公式先进行转化:设 n! = xx / 10^m = y (1<= y <10)则m+1为所求。因为是求位数,所以设y=1,对结果没影响则x = 10^m = n!m = log10(n!) m = log10(n) + log10(n-1) + ...+log10(1)
Powered by: C++博客 Copyright © 大胖