Group Abstract Group Abstract

Message Boards Message Boards

2
|
7.9K Views
|
4 Replies
|
6 Total Likes
View groups...
Share
Share this post:

Factorials and how many zeroes are at the end

POSTED BY: Peter Burbery
4 Replies
Posted 3 years ago
POSTED BY: Chase Marangu

For arbitrary bases I think this should do what you want.

factorialZeros[n_Integer, b_Integer] /; n > 1 && b > 1 := 
 Module[{pfacs, pexpons},
  {pfacs, pexpons} = Transpose[FactorInteger[b]];
  Min[Floor[
    Map[Sum[Floor[n/#^j], {j, Floor[Log[#, n]]}] &, pfacs]/pexpons]]
  ]

For example:

In[86]:= factorialZeros[243, 12]

(* Out[86]= 118 *)
POSTED BY: Daniel Lichtblau

Would Block work here because it takes less time or should Module be used?

POSTED BY: Peter Burbery
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard