Mod 10 Algorithm

Published by Matt in

Create a function that takes a number and checks whethers the given number is a valid credit card number using Luhn Algorithm. The return value is boolean.

Examples

valid_credit_card(4111111111111111) ➞ true
# Visa Card

valid_credit_card(6451623895684318) ➞ false
# Not a valid credit card number.

valid_credit_card(6451623895684318) ➞ false

Notes

  • American Express/VISA/Discover/Diner Club may be the credit card type.
  • Check the Resources for help.
Watch a quick demo on how Edabit works.