1
0
Fork 0
mirror of https://gitlab.com/mfocko/CodeWars.git synced 2024-09-19 22:16:57 +02:00
CodeWars/5kyu/number_of_trailing_zeros_of_nf/solution.cs

17 lines
275 B
C#
Raw Normal View History

using System;
public static class Kata
{
public static int TrailingZeros(int n)
{
var sum = 0.0;
var max = Math.Floor(Math.Log(n)/Math.Log(5));
for (var i = 1; i <= max; i++) {
sum += Math.Floor(n / Math.Pow(5, i));
}
return (int) sum;
}
}