How to resolve the algorithm Luhn test of credit card numbers step by step in the MUMPS programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Luhn test of credit card numbers step by step in the MUMPS programming language
Table of Contents
Problem Statement
The Luhn test is used by some credit card companies to distinguish valid credit card numbers from what could be a random selection of digits. Those companies using credit card numbers that can be validated by the Luhn test have numbers that pass the following test:
For example, if the trial number is 49927398716:
Write a function/method/procedure/subroutine that will validate a number with the Luhn test, and use it to validate the following numbers:
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Luhn test of credit card numbers step by step in the MUMPS programming language
Source code in the mumps programming language
LUHN(C)
NEW ODD,EVEN,S
SET S=$REVERSE(C)
SET ODD=0 FOR I=1:2:$LENGTH(S) SET ODD=ODD+$EXTRACT(S,I)
SET EVEN=0 FOR I=2:2:$LENGTH(S) SET T=$EXTRACT(S,I)*2 SET EVEN=EVEN+$SELECT(T<=9:T,T>9:$EXTRACT(T,1)+$EXTRACT(T,2))
QUIT '((ODD+EVEN)#10)
You may also check:How to resolve the algorithm Averages/Mode step by step in the Mathematica / Wolfram Language programming language
You may also check:How to resolve the algorithm Hello world/Text step by step in the Picat programming language
You may also check:How to resolve the algorithm Array concatenation step by step in the Racket programming language
You may also check:How to resolve the algorithm 99 bottles of beer step by step in the NetRexx programming language
You may also check:How to resolve the algorithm Successive prime differences step by step in the Delphi programming language