Last Digit

Easy · rating 850 · math

Read an integer n. Print its last (ones) digit, ignoring sign.

Editorial

Last Digit extracts the ones digit of a number, ignoring its sign: take the absolute value modulo 10.

print(abs(n) % 10)

Complexity

Time: O(1). Space: O(1).

Open Last Digit in Code Arena →