The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
(49g 50g) Number of Trailing Zeros in N!
06-02-2022, 08:51 PM (This post was last modified: 07-23-2022 07:32 PM by John Keith.)
Post: #1
(49g 50g) Number of Trailing Zeros in N!
Inspired by this program and others by member GeraldH, this program will return A027868(n), the number of trailing zeros in n!.

Using ListExt 1.3, it is reasonably small and very fast, even for numbers with over 100 digits. The program is based on the third comment in the OEIS link above.

Code:

\<< DUP I\->R 5. \>=        @ Check that n >= 5
    { 5 I\->BL REV TAIL     @ Base 5 digits of n
      1 5 PICK3 SIZE LMSEQ  @ List of powers of 5
      :: + LSCAN            @ A003463
      * LSUM }              @ Sum of products
    { DROP 0 } IFTE         @ Return 0 for n<5
\>>
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(49g 50g) Number of Trailing Zeros in N! - John Keith - 06-02-2022 08:51 PM



User(s) browsing this thread: 3 Guest(s)