Daily Challenge (246 Part Series)
For a given list
[x1, x2, x3, ..., xn] compute the last (decimal) digit of
x1 ^ (x2 ^ (x3 ^ (... ^ xn))).
last_digit([3, 4, 2]) == 1
3 ^ (4 ^ 2) = 3 ^ 16 = 43046721.
Beware: Powers grow incredibly fast. For example,
9 ^ (9 ^ 9) has more than 369 million of digits.
lastDigit has to deal with such numbers efficiently.
Corner cases: We assume that
0 ^ 0 = 1 and that
lastDigit of an empty list equals to 1.
Want to propose a challenge idea for a future post? Email email@example.com with your suggestions!
Claim your page on DEV before someone else does
Level up every day