diff --git a/maths/last_digit.py b/maths/last_digit.py new file mode 100644 index 000000000000..9309a0722833 --- /dev/null +++ b/maths/last_digit.py @@ -0,0 +1,12 @@ +def last_digit(number: int) -> int: + """ + Return the last digit of a given integer. + + >>> last_digit(1234) + 4 + >>> last_digit(-98) + 8 + >>> last_digit(0) + 0 + """ + return abs(number) % 10