I am trying to implement Luhn's Algorithm for validating credit cards, there is a step where we reverse the card number, why is it necessary to reverse the number?
The Luhn algorithm involves doubling every other digit in the number, such that the rightmost digit (the check digit) is NOT doubled. This means that the leftmost digit may or may not be doubled, depending on whether the number has an odd or even quantity of digits. One way of dealing with this variation would be to reverse the number, and always start with a non-doubled digit - but that seems like overkill to me; there are various solutions (such as indexing through the digits in reverse order) that are less work than reversing a number.