From 7626fcb24af562c8f1d10c951f6fc0338a0df26b Mon Sep 17 00:00:00 2001 From: Lubos Kolouch Date: Tue, 23 May 2023 20:35:24 +0200 Subject: feat(challenge-072,218/lubos-kolouch/perl,python/): Challenges 072 and 218 LK Perl Python --- challenge-072/lubos-kolouch/python/ch-1.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 challenge-072/lubos-kolouch/python/ch-1.py (limited to 'challenge-072/lubos-kolouch/python/ch-1.py') diff --git a/challenge-072/lubos-kolouch/python/ch-1.py b/challenge-072/lubos-kolouch/python/ch-1.py new file mode 100644 index 0000000000..c61b1f14bc --- /dev/null +++ b/challenge-072/lubos-kolouch/python/ch-1.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + + +def trailing_zeros(n: int) -> int: + count = 0 + i = 5 + while n // i >= 1: + count += n // i + i *= 5 + return count + + +# Test cases: +print(trailing_zeros(10)) # Output: 2 +print(trailing_zeros(7)) # Output: 1 +print(trailing_zeros(4)) # Output: 0 -- cgit