Luhn Check Test: How the Mod 10 Algorithm Works

Our Cards

Choose from any of our gift cards to give to your loved ones

giftcardimage

Where to Use?

Redeem your gift cards at any of our Merchants

Where to Buy?

You can purchase a gift card from any of these locations

ABOUT US

about

What is ONYX GiftCards?

Onyx Gift Cards is a Grenadian company designed to introduce, market and manage gift cards systems in Grenada for retailers and corporations. We are enthusiastic about the effect and influence we will have on the local market. We intend to expand our systems regionally with a range of product offerings and services.

What is a Gift Card?

Gift cards are the preferred way of giving and receiving gifts. They carry a monetary value that can be redeemed for gifts at your favorite store.
Onyx GiftCards are “Open Gift Cards” which means that they can be redeemed at multiple merchant locations. They are standard credit card size, can fit into the average wallet and made of PVC plastic. Onyx GiftCards are Barcoded for security and safety for the consumer and bear a disclaimer at the back.
Onyx Giftcards can be bought with a branded Card backer which is black in colour and is designed to fit the card. There is an area to write a brief message to the recipient as well.

How it Works?

  • Buy an Onyx Gift Card at these local stores
  • Give your gift card to friends, family, co-workers, etc.
  • The recipient can shop at our select merchants nationwide
  • Your friends, family, co-workers, etc. will present their gift card at checkout to pay for your item(s)
  • They will walk away happy with the best gift ever...the gift of Choice

Why ONYX GiftCards?

  • Save TIME. No need to run around looking for the perfect gift
  • Redeem from a variety of business island-wide. We will continue adding businesses as fast as ONYX grows.
  • ONYX Gift Cards do not expire
  • Cards are valued at convinient amounts to meet every need and occasion

A Luhn check test runs the Luhn algorithm, also called the mod 10 algorithm, over a string of digits to confirm it passes a simple checksum. When the digit sum is divisible by 10, the number is structurally valid; when the remainder is anything else, at least one digit is wrong or out of place.

The test takes a few lines of code and catches the most common typing mistakes before a number reaches a database. Payment card numbers, IMEI codes, and several national identifier formats all rely on it.

How the Luhn algorithm works

  1. Write the digits in order, then count from the rightmost digit, which sits in position 1.
  2. Double the value of every digit in an even position (2, 4, 6 and so on).
  3. If a doubled result is greater than 9, subtract 9 from it. This is the same as adding the two digits of the result together.
  4. Add the doubled digits to the digits you left alone.
  5. Divide the total by 10. A remainder of 0 means the number passes.

Worked example

Start with the digits 7 9 9 2 7 3 9 8 7 1 3. Counting from the right, the digits in even positions are 1, 8, 3, 2 and 9. Doubling them gives 2, 16, 6, 4 and 18. After subtracting 9 from 16 and 18, the doubled set becomes 2, 7, 6, 4 and 9.

The digits left alone are 3, 7, 9, 7 and 7. Adding both groups: 2 + 7 + 6 + 4 + 9 + 3 + 7 + 9 + 7 + 7 = 70. Since 70 divides evenly by 10, the string passes the check. Change any single digit or swap two adjacent digits and the total usually stops being a multiple of 10, which is the property the algorithm is designed to exploit.

What a Luhn check test cannot tell you

Treat the test as a typo filter and a format check, not as evidence about the number itself.

Where the check digit shows up

Testing your own implementation

Known vectors keep your code honest. The string 79927398713 passes, while 79927398710 through 79927398712 and 79927398714 through 79927398719 all fail. Run the same input twice with spaces and hyphens added to confirm your normalization step works, then try an empty string, a string with letters, and an input longer than 32 bits to check for overflow.

Common implementation mistakes

Contact Us

Latest

Buy CVV: A Comprehensive Buying Guide

Discover the ins and outs of purchasing CVVs with our expert buying guide. Learn the essentials, avoid common pitfalls, and get answers to frequently asked questions.

Buying Guide: Exchange CVV Dumps for Cash

Discover the ins and outs of exchanging CVV dumps for cash, including essential tips, what to look for, pitfalls to avoid, and a FAQ section to help you navigate this complex market safely.

Read our complete guide: Should You Buy CVV From a Card Shop? The Honest Buyer's Guide