Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Verify a credit or debit card's payment account number
ResourceFunction["ValidPANQ"][int] returns True when int is a valid Payment Account Number (PAN). |
Verify whether this 16-digits Visa Payment Account Number is valid:
| In[1]:= |
| Out[1]= |
ValidPANQ has the Listable attribute, so one can check whether the MasterCard and AMEX Payment Account Numbers with a length 16 and 15 digits, respectively are valid:
| In[2]:= |
| Out[2]= |
About 10% of possible values are valid:
| In[3]:= |
| Out[3]= |
The Luhn algorithm is used in many Identity Numbers, such as the International Mobile Equipment Identity (IMEI) numbers. In this case, the Luhn algorithm works in reverse. Therefore, we have to reverse the IMEI number without the last digit (which functions as a check-digit). We can verify the validity of an IMEI number with ValidPANQ:
| In[4]:= | ![]() |
| Out[4]= |
Wolfram Language 13.0 (December 2021) or above
This work is licensed under a Creative Commons Attribution 4.0 International License