Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class TrailingZeros
- {
- static uint CountZero(uint number)
- {
- uint zeroCount = 0;
- if (number % 5 == 0)
- {
- zeroCount++;
- zeroCount += CountZero(number / 5);
- }
- return zeroCount;
- }
- static void Main()
- {
- Console.Write("Input positive integer number N ");
- uint n = uint.Parse(Console.ReadLine());
- uint zeroCount = 0;
- for (uint i = 1; i <= n; i++)
- {
- zeroCount += CountZero(i);
- }
- Console.WriteLine("There are {0} trailing zeros in {1}!", zeroCount, n);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement