Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4267822
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T06:57:06+00:00 2026-05-21T06:57:06+00:00

Do you know why the Luhn mod N algoritm in order to create the

  • 0

Do you know why the Luhn mod N algoritm in order to create the check digit performs a sum by doubling the value of each even placed char instead of perfoming a simple sum of all chars?

In pseudo-code words:

given:

var s = "some string i want to create check digit";

do you know why Luhn mod N does basically this:

for(i from s.length-1 to 0)
   if(i is even)
      checkdigit += chr2int(s[i]) * 2;
   else
      checkdigit += chr2int(s[i]);

instead of simply doing a sum

for(i from s.length-1 to 0)
   checkdigit += chr2int(s[i]);

they can still both terminate with a mod operation to make the checkdigit fit into one char

return int2chr( chr2int('a') + (checkdigit mod 25) );

As a side note to this question, to whom it may be interested in a graphic representation of the Luhn algorithm that makes it even more simple to understand:

enter image description here

Actually this one is the original Luhn algorithm that does not even needs to use MOD function.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T06:57:07+00:00Added an answer on May 21, 2026 at 6:57 am

    Checkdigit characters are designed to prevent accidental mangling of an input, for example when a clerk enters the number via keyboard.

    If just a sum is used both strings “ABCD” and “ABDC” would yield the same checksum (“A” + “B” + “C” + “D”), so simple swap errors could happen unnoticed.

    However, taking parity into consideration, “ABCD” and “ABDC” will become (2″A” + “B” + 2″C” + “D”) and (2″A” + “B” + 2″D” + “C”) respectively, which are (likely) different numbers, so in this way we could detect if two characters were inadvertently swapped.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Excluding the check digit, what is the minimum length number the luhn algorithm will
I know you can not set a key value dynamically, but what about the
Anyone know how to get the id of multiple placemarks each one created with
I have a 15 digit customer number that I need to calculate a check
Know someone, how to create Browse for folder dialog in Adobe FLEX? And it
I know I can create an NSArray with @[@foo, @bar] or an NSDictionary with
Know this might be rather basic, but I been trying to figure out how
Know if it's possible to access the iPhone compass in Safari using JavaScript? I
I know that Phonegap has an event for back button, but it's only available
I know there have been many questions on grid and pack in the past

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.