loading...

re: Daily Challenge #250 - Last Digit of a Large Number VIEW POST

TOP OF THREAD FULL DISCUSSION
re: ruby def last_digit(a, b) (a**b).digits.first end or def last_digit(a, b) (a**b).to_s[-1].to_i end
 

I think this Ruby solution underestimates the complexity required with huge numbers, although the .digits.first is clever! Using a mod 10 solution, like some of the solutions above, would greatly reduce the time/space complexity. brilliant.org/wiki/finding-the-las...

code of conduct - report abuse