POV-Ray : Newsgroups : povray.off-topic : Some math problems : Re: Some math problems Server Time
8 Oct 2024 20:51:16 EDT (-0400)
  Re: Some math problems  
From: Sabrina Kilian
Date: 23 Sep 2009 00:04:45
Message: <4ab99e5d$1@news.povray.org>
Warp wrote:
>   4) By their nature, factorials tend to accumulate trailing zeroes. For
> example, 5! (120) has one trailing zero, 10! (3628800) has two trailing
> zeroes, 25! (15511210043330985984000000) has six trailing zeroes, etc.
> 
>   Give a (non-recursive) mathematical function which, for an integer n,
> gives the number of trailing zeroes in n!.
> 

I think I have a numerical solution, but I do not have the formulas to
write the equation. Yet. . .

What you are interested in is the number of numbers, less than n, that
end in 5, or 0. Five times any even number will result in a multiple of
10 and have add zero at the end. All factorials after 2! are even, given
that 2 is even and they are all multiplied by 2 by recursion.

So, to solve for the number of integers that are multiples of 10, X =
floor(N/10), but save the remainder of N/10 as R. Y, the number of
integers <N ending in 5s, can be gotten via R. Y = floor(R/5)+X. Number
of zeros would be X + Y.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.