From 73e99171db69fc922f25171670022cd3269fa5b8 Mon Sep 17 00:00:00 2001 From: prachi757 Date: Wed, 16 Jul 2025 16:09:19 +0530 Subject: [PATCH] Add last_digit function with type hints and doctests --- maths/last_digit.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 maths/last_digit.py diff --git a/maths/last_digit.py b/maths/last_digit.py new file mode 100644 index 000000000000..c3a7e4c32383 --- /dev/null +++ b/maths/last_digit.py @@ -0,0 +1,12 @@ +def last_digit(n: int) -> int: + """ + Return the last digit of a given integer. + + >>> last_digit(1234) + 4 + >>> last_digit(-98) + 8 + >>> last_digit(0) + 0 + """ + return abs(n) % 10