3 kyu
Last digit of a huge number
4,614 of 7,907Bodigrim
Description:
For a given list [x1, x2, x3, ..., xn]
compute the last (decimal) digit of
x1 ^ (x2 ^ (x3 ^ (... ^ xn)))
.
E. g., with the input [3, 4, 2]
, your code should return 1
because 3 ^ (4 ^ 2) = 3 ^ 16 = 43046721
.
Beware: powers grow incredibly fast. For example, 9 ^ (9 ^ 9)
has more than 369 millions 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.
This kata generalizes Last digit of a large number; you may find useful to solve it beforehand.
Algorithms
Mathematics
Similar Kata:
Stats:
Created | Mar 30, 2015 |
Published | Mar 30, 2015 |
Warriors Trained | 43969 |
Total Skips | 8499 |
Total Code Submissions | 166448 |
Total Times Completed | 7907 |
Haskell Completions | 177 |
JavaScript Completions | 1531 |
Python Completions | 4614 |
Go Completions | 223 |
Rust Completions | 306 |
C# Completions | 394 |
C++ Completions | 536 |
Swift Completions | 24 |
CoffeeScript Completions | 20 |
Ruby Completions | 156 |
C Completions | 292 |
Prolog Completions | 15 |
COBOL Completions | 17 |
Scala Completions | 9 |
Java Completions | 49 |
Total Stars | 1893 |
% of votes with a positive feedback rating | 87% of 1031 |
Total "Very Satisfied" Votes | 828 |
Total "Somewhat Satisfied" Votes | 144 |
Total "Not Satisfied" Votes | 59 |