Advertisement
Assi

TraillingZeros

Dec 11th, 2012
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.48 KB | None | 0 0
  1. using System;
  2.  
  3. class traillingZeros
  4. {
  5.     static void Main()
  6.     {
  7.         int n = 50000;
  8.         int sum = 1;
  9.         int result = 0;
  10.        
  11.             for (int i = 1; i <= n; i++)
  12.             {
  13.                 sum = n / (int)Math.Pow(5, i);
  14.                 result = result + sum;
  15.                 if (sum < 1)
  16.                 {
  17.                     break;
  18.                 }
  19.             }
  20.         Console.WriteLine("Trailling Zeros of {0}! are {1}",n,result);
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement