1
0
Fork 0
mirror of https://gitlab.com/mfocko/CodeWars.git synced 2024-11-22 08:33:48 +01:00
CodeWars/5kyu/number_of_trailing_zeros_of_nf/solution.cs
Matej Focko fc899b0b02
chore: initial commit
Signed-off-by: Matej Focko <mfocko@redhat.com>
2021-12-28 16:19:58 +01:00

16 lines
275 B
C#

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;
}
}