![]() If cnumber In function int sumodd(long cnumber) Step 4-> In function int getDigit(int cnumber) Set sum = sum + getDigit(Integer.parseInt(num.charAt(i) + "") * 2) ![]() Loop For i = thesize(cnumber) – 2 and i >= 0 and i -= 2 Return thesize(cnumber) >= 13 & thesize(cnumber) In function int sumdoubleeven(long cnumber) Step 2-> In function boolean validitychk(long cnumber) Step1-> In function void main(String args)ĭeclare and initialize cnumber = 4440967484181607L We will be using Luhn check or the mod 10 check, for the digit 4440967484181607. Example Input: n = 4440967484181607Īpproach we are using to solve the problem − Step 5 − If the result is divisible by 10 then the card number is valid else the number is not valid. Step 4 − Add up the results from Step 2 and Step 3. Step 3 − Add all the single digit number obtained from Step 1. Step 2 − Starting from right to left of the card number add all the digits at the odd places. Step 1 − Starting from the right to left we have to double each the digit, if the result of doubling the number is one digit then leave it as it is, else add up the two digit to get an one digit number. Steps to check whether the credit card is valid or not − 37 is the starting for American express cards.Given a long number containing digits of a credit card number the task is to find whether the credit card number is valid or not with a program.įor checking a credit card is valid or not, the following are the validations we have to be sure for declaring the result.Ī credit card’s number must have 13 to 16 digits, it must start with the following digits.
0 Comments
Leave a Reply. |