On Feb 12, 10:11 pm, Dave <[EMAIL PROTECTED]> wrote:
> On Feb 12, 8:17 pm, "[EMAIL PROTECTED]"
> <[EMAIL PROTECTED]> wrote:
> > how will u find the "number of digits in the factorial of a number"
> > without finding the factorial??- Hide quoted text -
>
> Sum log 1 + log 2 + log 3 + ... + log n, where log represents the
> base-10 logarithm function. The ceiling of the sum gives the number of
> digits.

True.  Or if you want a close answer fast, you can use Stirling's
approximation:

ln n! = n lg n - n + 1

These are natural logs.  To get log_10, just multiply by (lg e / lg
10) = (1 / lg 10).

This apparently gives answers within 1 digit even for small n.  If you
need better accuracy, you can use more terms from Stirling's series.
See for example

http://mathworld.wolfram.com/StirlingsApproximation.html
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---

Reply via email to