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