Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class TrailingZeroesInNFactorial
- {
- static void Main()
- {
- int n = int.Parse(Console.ReadLine());
- int countZero = 0;
- for (int i = 1; i <= n; i++)
- {
- if (i % 5 == 0)
- {
- if (i % 10 == 0)
- {
- countZero += GetZero(i);
- }
- else
- {
- countZero++;
- }
- }
- }
- Console.WriteLine(countZero);
- }
- static int GetZero(int number)
- {
- int count = 0;
- while (number % 10 == 0)
- {
- number = number / 10;
- count++;
- }
- return count++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement