Skip to content

securityeasy

Card Number Sanity Check

75 points · 0 solved

Payment forms reject typos before they ever reach the processor using the Luhn checksum. The first line is T; each next line is a card number that may contain spaces. Remove spaces; print VALID if what's left is 12–19 digits and passes the Luhn check, otherwise INVALID.

Luhn: from the rightmost digit, double every second digit (subtract 9 if the result is over 9), sum everything, and the total must be divisible by 10.

2
4539 1488 0343 6467
4539 1488 0343 6468
VALID
INVALID
Learn the technique/learn/secure-coding-in-practice

main.py