Questions tagged [luhn]

Luhn's Algorithm is a simple checksum formula used to generate the check digit in most credit card numbers.

The Luhn algorithm is well known with credit cards but is also used in various other applications like the IMEI for cell phones.

See: https://en.wikipedia.org/wiki/Luhn_algorithm

One of the exercises in the CS50 course (tag — also CS50 Stack Exchange) is implementing Luhn's Algorithm; the tag will often show up with the tag.

207 questions
0
votes
2 answers

The below function performs Luhn's Algorithm on a given card number, but throws up runtime error with some card numbers. Trying to understand why?

I am running below function to do a sumcheck (Luhn's Alrgorithm) on any given card numbers but the check fails on some of the card numbers and also throws up runtime error: "Index out of bounds for type 'int[count]'." I guess this is something about…
Rakesh Singh
  • 67
  • 1
  • 5
0
votes
2 answers

Wanted to check if a credit card number is valid or not

I wanted to check if a credit card number is valid or not but when i run the code, every number I give as input, the output comes as invalid. The example given below is what I should i do. Example with David’s Visa: 4003600000000014. For the sake…
user11004300
0
votes
1 answer

Unknown value in for loop for Luhn algorithm

i have this code and for some reasons i get a very large number at every iteration of the for loop and i can't figure out the logic. #include #include #include #include int main(void) { long CARD, digits,…
VanG
  • 55
  • 1
  • 9
0
votes
2 answers

How best to determine the digit to the left of the rigthmost number for numbers with odd and even length?

I am writing a code to check if a certain number of credit card number inputs is valid or not. I have written: function validCreditCard(value) { // accept only digits, dashes or spaces if (value.trim().length <= 1) return 'Value entered must…
camelCase
  • 475
  • 5
  • 14
0
votes
1 answer

(PL\SQL) Luhn check number generating

If I run a Luhn-formula check on a number sequence, and the return number is 0, the number sequence is valid (not randomly). I have a random number sequence, but I need a Luhn number generator, which return a number. This number should fill out the…
Black Cornail
  • 149
  • 1
  • 9
0
votes
1 answer

Multiple errors on Luhn Algorithm

I am trying to take a user input credit card number and put it into a Luhn algorithm. When i run the code I get a conversion='i' error. I am also getting a two digit number when calling 'check.' public static void main(String[] args) { Scanner…
Joshua
  • 3
  • 1
0
votes
1 answer

Luhn Algorithm Implementation into original code

Credit Card Number Validator