Hello everyone,

My friend and I are discussing about an interesting question, how to calculate efficiently how many 0s are at the end of N! (1 * 2 * 3 * ... * N-1 * N).

Our algorithm is like this,

1. Use a loop to calculate N!

2. Use a loop to calculate %10 result of N!, then /10 each step

Are there any better solutions?

regards,

George