From 5df7489f2758bfe17d45cd37c363cb853a41f715 Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Fri, 27 Oct 2023 16:12:17 -0400 Subject: [PATCH] Factorial trailing zeroes thing --- leetcode/stuff.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/leetcode/stuff.py b/leetcode/stuff.py index ca60fdd..835b6b9 100644 --- a/leetcode/stuff.py +++ b/leetcode/stuff.py @@ -498,3 +498,14 @@ class Trie: and (current_node.is_leaf or prefix_ok) and current_node.value == word ) + + +def count_factorial_trailing_zeroes(number: int) -> int: + divisor: int = 5 + zeroes_count: int = 0 + + while divisor <= number: + zeroes_count += number // divisor + divisor *= 5 + + return zeroes_count