How to resolve the algorithm Luhn test of credit card numbers step by step in the SenseTalk 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 SenseTalk 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 SenseTalk programming language
Source code in the sensetalk programming language
function LuhnCheck ccNum
put length of ccNum into numDigits
put the last character of ccNum into total
put numDigits modulo 2 into parity
repeat for each character of the first numDigits - 1 characters of ccNum
put it into digit
if (the counter - 1) modulo 2 equals parity
multiply digit by 2
end if
if digit is greater than 9
subtract 9 from digit
end if
add digit to total
end repeat
return total is divisible by 10
end LuhnCheck
repeat for each item of (49927398716, 49927398717, 1234567812345678, 1234567812345670)
put it && LuhnCheck(it)
end repeat
You may also check:How to resolve the algorithm Sorting algorithms/Sleep sort step by step in the Oforth programming language
You may also check:How to resolve the algorithm Decorate-sort-undecorate idiom step by step in the C programming language
You may also check:How to resolve the algorithm Sieve of Eratosthenes step by step in the Haskell programming language
You may also check:How to resolve the algorithm Elementary cellular automaton/Random number generator step by step in the Racket programming language
You may also check:How to resolve the algorithm History variables step by step in the AutoHotkey programming language