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
0 answers

Methods will only affect certain number?

So I'm trying to verify a credit card number by using a simple algorithm. I'm able to get some numbers through, but not all numbers, and I can't figure out why. class CreditCard def initialize(number) @number = (number.to_s.split("")).map! {…
0
votes
1 answer

How is there the arithmetic error of a division by zero in this function?

I have written an implementation of Luhn's algorithm. When I test the program with numbers that are invalid by the number of digits I get no program error. Instead, the program executes the printf() call in the main function. However, whenever I…
RonaldMunodawafa
  • 223
  • 3
  • 11
0
votes
0 answers

How to read XML File by using the LUHN Formula?

I already have the algorithm for the LUHN Formula and my XML file. But I need to implement the data inside the XML file for the LUHN Formula. Example: The 123-4567-891 Credit card number is stolen. And the LUHN Formula will read it then prints it…
0
votes
0 answers

Get possible luhn generated numbers from an incorrect luhn number

In a MySQL database, i have records with correct and incorrect luhn numbers (numbers that do not validate using the luhn algorithm). Assuming the wrong number is due to a typing error on one digit, i would like to get the list of possible correct…
cacaodev
  • 1
  • 1
  • 1
0
votes
2 answers

Program Freezing - Luhn's Algorithm

I am hoping someone can help me with this. I am a complete and utter C newbie. This is for a school assignment in a class on C (just plain old C, not C# or C++), and the professor is insistent that the only compiler we're allowed to use is Borland…
TeraBat
  • 3
  • 1
  • 4
0
votes
0 answers

Luhn Failed IMEI Number Required

I was in the middle of implementing the LUHN Check functionality into my application, but i just stuck in the developer testing. I was not able to find a valid IMEI number whose LuHN check must be failed. Please guys provide me the one. I know its…
HarshSharma
  • 630
  • 3
  • 9
  • 34
0
votes
3 answers

Calling the 1's, 10's, 100's... columns of an integer using a string array

I'm trying to convert a long long integer to a string array with the 1's column in position 0 of the array, the 10's column in position 1, the 100's column in position 2, like this: INPUT: 4444555566667777 -----> OUTPUT:…
Crowder
  • 187
  • 6
0
votes
1 answer

How do I search for a 16-digit long string (Luhn algorithm) using notepad++?

I have a large text file containing credit card numbers, I've been told I need to look through this file and then find possible credit card numbers, I've been using Notepad ++ 'Find in Files' regular expression search mode using this simple…
user2786228
  • 17
  • 2
  • 6
0
votes
4 answers

Sum of the odd-place digits

I am trying to sum every other digit in the card number by doing this: /* Return the sum of the odd-place digits. */ public static int sumOfoddPlace(long number) { int maxDigitLength = 16; int sum = 0; for (int i = 1; i <=…
Dan Gurewitch
  • 5
  • 2
  • 2
  • 4
0
votes
4 answers

Luhn Algorithm- Returning True for a False Credit Card

Having a little issue with my code to see if a credit card number adheres to the Luhn Algorithm. The code is returning true when the Credit Card is divisible by 10, but also is returning true when the CC number is not divisible by 10. I have printed…
0
votes
1 answer

Algorithms for detecting Credit Card Number reducing false positives/negatives

I would like to create an algorithm that could detect credit card numbers (CCNs) from various types of files. The simple scenario how to find CCNs is to use regular expressions as defined: Visa: ^4[0-9]{12}(?:[0-9]{3})?$ All Visa card numbers start…
user1563721
  • 1,373
  • 3
  • 28
  • 46
0
votes
3 answers

Luhn Algorithm in Ruby

I've been trying to implement the Luhn Algorithm in Ruby but keep getting the error message that nil cannot be corerced into Fixnum. The Luhn Algorithm is supposed to: Starting with the second to last digit, double every other digit until you…
0
votes
2 answers

Luhn algorithm issues

I decided to use the Luhn alghorithm to validate some swedish social security numbers. By writing the function myself i got this to work as planned, although there are some issues. With my code and the others i've tried i've found out that it still…
Markus
  • 616
  • 1
  • 9
  • 24
0
votes
1 answer

PayPal Pro: is credit card validation really necessary?

Since PayPal charges transactions but not payment authorizations, I was wondering what is the point of doing credit card validation with Luhn algorithm? I happen to have trouble with CC validation. If it turns out not to be very important, I could…
drake035
  • 3,955
  • 41
  • 119
  • 229
0
votes
1 answer

Faulty Luhn algorithm function?

In my PayPal Pro credit card payment system, I use the Luhn algorithm function given in the first answer to this question. However, I have several US clients who apparently tried to pay with their credit cards and their details were rejected by the…
drake035
  • 3,955
  • 41
  • 119
  • 229