Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Numerics;
- namespace _04b_MethodsDebuggingTroubleshootingCode_Exercises
- {
- class MethodsDebuggingTroubleshootingCode_Exercises
- {static void Main(string[] args)
- {
- BigInteger num = BigInteger.Parse(Console.ReadLine());
- Console.WriteLine($"{CalculateTrailingZeroes(Factorial(num))}");
- }
- static BigInteger Factorial(BigInteger num)
- {
- if (num <= 1)
- return 1;
- return num * Factorial(num - 1);
- }
- static int CalculateTrailingZeroes(BigInteger num)
- {
- int zeroesCounter = 0;
- while (num % 10 == 0)
- {
- zeroesCounter++;
- num /= 10;
- }
- return zeroesCounter;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment