add new solutions

This commit is contained in:
kanna5 2026-01-05 16:48:03 +09:00
parent 9c2c959a9b
commit 9a10695e8c
Signed by: kkyy
GPG key ID: 06332F3965E9B0CF
29 changed files with 1074 additions and 2 deletions

View file

@ -0,0 +1,21 @@
package q172
// Note: actually, counting 5 alone is enough since 2 certainly occurs more than 5.
func trailingZeroes(n int) int {
count2, count5 := 0, 0
for i := 2; i <= n; i++ {
num := i
for num%2 == 0 {
num /= 2
count2++
}
for num%5 == 0 {
num /= 5
count5++
}
}
return min(count2, count5)
}
var _ = trailingZeroes