Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.72 KB | None | 0 0
  1. using System;
  2.  
  3. namespace TrailingZerosInN
  4. {
  5.     class MainClass
  6.     {
  7.         public static void Main(string[] args)
  8.         {
  9.             long n = long.Parse(Console.ReadLine());
  10.             long countZero = 0;
  11.  
  12.             for (int i = 1; i <= n; i++)
  13.             {
  14.                 if (i % 5 == 0)
  15.                 {
  16.                     countZero += GetFive(i);
  17.                 }
  18.             }
  19.  
  20.             Console.WriteLine(countZero);
  21.         }
  22.  
  23.  
  24.         static int GetFive(long number)
  25.         {
  26.             int count = 0;
  27.             while (number % 5 == 0)
  28.             {
  29.                 number = number / 5;
  30.                 count++;
  31.             }
  32.             return count++;
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement