Tag: algorithms

  • The Math in Credit Card Security

    The Math in Credit Card Security

    We had a fun little discussion via email at the day-job. Someone changed the code on the combination lock and the discussion around combinations, permutations, cryptography and all things sneaky-math cranked up.

    It reminded me of this neat fact I learned about credit card security.

    Not all digits on a credit card are created equally!

    A credit card is made up of 16 numbers. But only the first 15 are “random,” according to NRich Math. The last number – the 16th number – is the “check digit.” It’s calculated using a fancy formula using the first 15 digits.

    This check digit helps a computer system quickly determine if a credit card number is fake. Now, it can’t confirm that it’s real – it just can help determine if it is fake.

    The digit is created using a method called Codabar.

    First, let’s define some things.

    An odd digit is a digit in the credit card number that is in an odd position. For the photo of the card here, the number is: 5184 8204 5526 6423:

    The odd digits are 5, 8, 8, 0, 5, 2, 6, 2

    An even digit is a digit in the credit card number that is in an even position. For the photo of the card here, even digits are 1, 4, 2, 4, 5, 6, 4, 3

    The check digit is the last digit – it gets calculated and isn’t considered in either odd or even position. It’s a super special digit.

    The method is weird – and kinda fun!

    Here’s what you do:

    1. Add up all the odd digits, or the digits in the odd positions: 5 + 8 + 8 + 0 + 5 + 2 + 6 + 2 = 36
    2. Double that number: 36 × 2 = 72. Save this number, 72, for later…
    3. Add the even digits together, or the digits in the even positions: 1 + 4 + 2 + 4 + 5 + 6 + 4 + 3 = 29. Save this number, 29, for later…
    4. (This is a freaky step.) Count the number of odd digits that are greater than 4. The odd digits are 5, 8, 8, 0, 5, 2, 6, 2. Of these, 5, 8, 8, 5 and 6 are bigger than 4. There are 5 of those total. Save this number, 5,  for this next step…
    5. Add up the results you saved from steps #2, #3 and #4. 72 + 29 + 5 = 106
    6. Take the answer from step #5 and figure out how many you need to add to get it to the next multiple of 10 (or the next number that ends in zero). The number after 106 that ends in zero is 110. So we need to add 4. 106 + 4 = 110. 4 is the super important number.
    7. That final super important number – well, that’s the check digit! That’s the last number that should be on the credit card – if it were a real card!

    For the picture, the check digit should be a 4. And it’s a 3. So I can tell instantly that this is a fake credit card number.

    You can use this to teach your children!

    Stuck in a waiting room with a 10-year-old? All you need is a pen, piece of paper and any credit card in your wallet.

    Teach them the method and have them check all of your credit cards. Or tell them you can guess the last digit of any credit card number.

    Either way, you’ve got an instant source of entertainment wrapped in a ball of education!

    What do you think? Are you racing to your purse right now to check your cards? Share your thoughts in the comments.

    Related articles
  • Why It’s Okay to Teach Algorithms

    We had a lively discussion at last week’s homeschool math chat about teaching algorithms versus allowing a discovery learning process.

    What I can’t help but think about when I reread this discussion is how this compares to teaching a child manners.

    Teach kids manners early. Very early.

    I know someone who elected to wait until their child understood the concept of appreciation before teaching them how to say thank you. The child is now eight years old and doesn’t say thank you unless prompted.

    Daughter, at 18 months old, is being taught please, thank you, ma’am and sir. She has no concept of being polite. Her frontal lobe is about as advanced as the local neighborhood chimpanzee’s. Her favorite phrase these days is, “No. Mine.” I correct this with, “No ma’am.”

    At some point it will become habit. Or at least the ritual of, “No,” from her and my “No ma’am” response will become habit.

    And at some point shall make the connection that using these polite words will gain her something. She’ll be looked upon favorably, considered one of the “good kids,” or smiled at a little more.

    And then she’ll connect it. She’ll see that the concept of politeness is directly tied to the “algorithm” of saying polite words.

    Teach kids algorithms early. Very early.

    I love the idea of teaching concepts before algorithms in math. But sometimes algorithms have to come first so that the rhythm and habit are in place when the brain is ready to understand the concept.

    Each child’s brain is different. One of the beauties of homeschooling and private tutoring is that you can focus on a child and know when they’re ready for algorithms and ready for concepts. As a classroom teacher, it’s a little bit more difficult, but still can be done.

    In the classroom you can teach algorithms at the same time as concepts. If you cycle them back and forth, you can catch each student as they are prepared to accept the learning.