Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- //Write a program that calculates with how many zeroes the factorial of a given number n has at its end.
- // Your program should work well for very big numbers, e.g. n=100000
- class TrailingZeroesInN
- {
- static void Main()
- {
- BigInteger n = BigInteger.Parse(Console.ReadLine());
- BigInteger nFaktorial = 1;
- for (int i = 1; i <= n; i++)
- {
- nFaktorial *= i;
- }
- Console.WriteLine(nFaktorial);
- int count = 0;
- while (nFaktorial % 10 == 0)
- {
- count++;
- nFaktorial = nFaktorial / 10;
- }
- Console.WriteLine("Zeros = " + count);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement