digits.first should probably be digits.last, right?

This won't work for big numbers btw, the last example will raise an exception:

last_digit(2**200,2**300)(irb):2:warning: ina**b,bmaybetoobigTraceback(mostrecentcalllast):...NoMethodError(undefinedmethod`digits' for Infinity:Float)

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...

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

FULL DISCUSSIONruby

or

`digits.first`

should probably be`digits.last`

, right?This won't work for big numbers btw, the last example will raise an exception:

no digits in ruby

so digits.first is correct

Ah yes, somehow I was thinking this would have the same order as

`chars.to_a`

, but it doesn't, so you can easily get back the number: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...