asked in Algebra by anonymous

1 Answer

Hi anonymous.

To find the number of trailing zeros you can use a computer program like the one below adapted  from http://www.geeksforgeeks.org/count-trailing-zeroes-factorial-number/ by following the instructions found here:  https://en.wikipedia.org/wiki/Trailing_zero.

// Function to return trailing 0s in factorial of n
// http://www.geeksforgeeks.org/ count-trailing-zeroes-factorial-number/
function findTrailingZeros($n) {
// Initialize result
$count = 0;
// according to https://en.wikipedia.org/ wiki/Trailing_zero
$i=5;
while(floor($n/$i) >= 1) {
$count += floor($n/$i); $i=$i*5;}
return floor($count);
}
} 

The code above is written in PHP, but can be translated easely to many other computer languages. 

It was adapted from the code below. I don't remember very well, but there is a issue with the original code shown below.

// C++ program to count trailing 0s in n! 
#include <iostream>
using namespace std;
 // Function to return trailing 0s in factorial of n 
int findTrailingZeros(int n)
 { // Initialize result
int count = 0; 
// Keep dividing n by powers of 5 and update count for (int i=5; n/i>=1; i *= 5)
count += n/i; 
return count;
}

You can also check this calculator factorial calculator here (click). As you can see, the number of trailing zeros in 70 factorial is 16.

IFactorial Calculator

Click here to access this factorial calculator.

answered by questiun