This Problem is solved using Luhn's Algorithm :-
Steps involved in Solving this problem are as follows :-
Step 1. Double every second digit from left to right at the Odd Indexes . If doubling of a digit results in a two-digit number, add up the two digits to get a single-digit number (like for 12:1+2, 18=1+8).
Step 2. Now add all single-digit numbers from Step 1.
Step 3. Add all digits at the even indexes from left to right in the card number.
Step 4. Sum the results from Step 2 and Step 3.
Step 5. If the result from Step 4 is divisible by 10, the card number is valid; otherwise, it is invalid.