To generate a gift card number:
Choose the final length of the number and subtract one from it.
Pick a random number that matches the length of the previous step (after subtracting one).
Multiply by two every other digit starting from the last one.
If any of the new numbers is greater than or equal to 10, subtract 9 from it.
Add all the resulting digits and write down this number.
Take the mod 10 of this final number.
Append this digit to your initial number. This number will pass a Luhn validation and be a valid gift card number. Congrats!
Read more