Skip to content

sachinprasad/checkdigit-barcode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

checkdigit-barcode

Write best practice code in ruby to calculate the check digit of an ISBN13 barcode

The algorithm is:

  1. Take each digit, from left to right and multiply them alternatively by 1 and 3
  2. Sum those numbers
  3. Take mod 10 of the summed figure
  4. Subtract 10 and if the end number is 10, make it 0 Example for 978014300723:
  5. (9×1) + (7×3) + (8×1) + (0×3) + (1×1) + (4×3) + (3×1) + (0×3) + (0×1) + (7×3) + (2×1) + (3×3)
  6. 86
  7. 86 mod 10 = 6
  8. 10 - 6 = 4 Therefore the complete ISBN is: 9780143007234

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages