number is a sequence of digits, the element
at index zero represents the left-most digit, the right-most digit is
the last element in the array.
isValid should return the String "YES" if the
number represents a valid sequence according
to the Luhn algorithm and "NO" if the sequence is not valid.
public String isValid(int number)(be sure your method is public)
numberrepresents a sequence of digits to be checked for validity. The element at index zero of the array represents the left-most digit in the sequence.
numberwill have at least one element and no more than 50 elements.
numberwill be between 0 and 9 inclusive.
number = [1,2,1,4]Returns: "YES"
The Luhn algorithm generates a sum from right-to-left of 4 + 1*2 + 2 + 1*2 = 10 which is divisible by 10 and thus a valid number/sequence.
number = [1,7,2,3,6]Returns: "YES"
The Luhn algorithm generates (from right-to-left) 6 + 6 + 2 + 5 + 1 = 20 which is divisible by 10.
number = [7,8,3]Returns: "NO"
The Luhn algorithm generates (from right-to-left) 3 + 7 + 7 = 17 which is not divisible by 10.