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
1 answer

PayPal Pro : is it sufficient to check for non valid credit card numbers?

Right before doing a PayPal Pro payment, I check the credit card number with the Luhn algorithm. I know this only rules out invalid numbers, not malicious attacks (valid but non authentic numbers). Is it still considered acceptable to proceed this…
drake035
  • 3,955
  • 41
  • 119
  • 229
-1
votes
3 answers

CS50 Luhn's Algorithm Problem Mistaks Invalids card with Visa

The programm identifies this invalid cards as Visa (4111111111111113, 4222222222223). I really don't know how to solve this problem. The program pass all other checks expet these two and I don't know where it goes wrong. I think the problem in the…
-1
votes
1 answer

Trying to implement Luhn's algorithm in C, but not getting expected sum of every other digit

I'm trying to implement Luhn's algorithm. For every other digit you have to take it, multiply it by 2, and add it to a running total. If the ith digit * 2 is greater than 10, you split it up, and just add it to the running total. I create a void…
Shah
  • 3
  • 4
-1
votes
1 answer

Create a function, validateCred() that has a parameter of an array. Scope of variables

I'm learning Javascript on Codecademy and have gotten stumped by a problem. I believe my issue is with the scope of my iterator tracker but not too sure. Here are the directions given to me: "Create a function, validateCred() that has a parameter of…
-1
votes
1 answer

Why does VISA (4111111111111111) does not return anything?

I am very new to programming and so, please help me with this Luhn's algorithm problem. Everything works right except with a Visa 411111111111111. what actually is causing the error? I know copy pasting is considered a bad code but I…
-1
votes
1 answer

Replace each elements of a list by another iterating each one of them

I'm using luhn algorithm to check credit card numbers (Visa or MasterCard). I have two list: credit_card_number_checked = [random numbers generated] : credit card numbers checked by luhn algorithm check_numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] When…
Y4RD13
  • 937
  • 1
  • 16
  • 42
-1
votes
2 answers

How to concatenate two integer numbers into a String (python)?

Trying to calculate a check-digit and add it to the end of generated credit card. So i want to concatenate two integers into a string. Problem is that this chunk of code generates a LIST of numbers rather than a number itself.. checkDigit = 0 while…
-1
votes
1 answer

new to C; using pow() in a for loop

I'm trying to work through pset1 in Harvard's CS50 class through edX/ iTunesU and I'm attempting to program Luhn's algorithm. The below code is very incomplete but I wanted to know how to use pow() within a for loop and utilizing i within pow().…
-1
votes
4 answers

Credit program doesn't compile

I tried to make a C program that checks if a bank card is valid. According to Luhn’s algorithm, you can determine if a credit card number is (syntactically) valid as follows: Multiply every other digit by 2, starting with the number’s second-to-last…
wang ray
  • 27
  • 1
  • 10
-1
votes
3 answers

Programming a Luhn Algorithm in Java

I'm trying to program the Luhn Algorithm within Java. My current code is : import java.util.Scanner; public class luhnAlgorithm { public static void main(String[] args) { System.out.println("main() : Entry Point"); Scanner input = new…
jon
  • 29
  • 1
  • 3
-1
votes
1 answer

Luhn check digit

I cant seem to figure out what is wrong with my check digit code! At times, it produces 2 length check digit values Example 1277531815000110 <-- check digit is double value?????? 1277532495000110 <-- check digit is double…
001
  • 62,807
  • 94
  • 230
  • 350
-1
votes
1 answer

How to validate a text entered in spinner?

In my application i have created a separate class for credit card validation.I have called credit card validation class as a method in main activity and in my main activity i have listed the card names in spinner list. For card number validation i…
june
  • 999
  • 3
  • 14
  • 20
-1
votes
1 answer

Can't use Luhn algorithm to validate credit cards

I have a problem with using the Luhn algorithm to validate credit cards. I'm using this c# code: void ServerValidation(object source, ServerValidateEventArgs args) { // use a RequiredFieldValidator to check for an empty value if…
user2157063
  • 49
  • 2
  • 10
-2
votes
1 answer

I am making a code for validation of credit card but facing some error

credit = "1234 2347 1845 9023" credit_card = credit.replace('-','').replace(' ','') a = len(credit_card) sum_1 = 0 sum_2 = 0 sum = 0 list_even = [] for i in range (a,0,-1): if i%2 != 0: sum = sum + int(credit_card[i]) else: …
-2
votes
1 answer

Luhn algorithms in C cs50

#include #include int main(void) { long firsttwodig; long cardnumber; int sum = 0; int count = 0; cardnumber = get_long("card number:"); firsttwodig = cardnumber; //first case of luhn alg …
1 2 3
13
14