Thursday Code Puzzler: ISBN Validator
Join the DZone community and get the full member experience.
Join For Freethursday is code puzzler day here at dzone. the idea is simple: solve the coding problem as efficiently as you can, in any language or framework that you find suitable.
note: even though there really is nothing stopping you from finding a solution to this on the internet, try to keep honest, and come up with your own answer. it's all about the participation!
do you have code puzzlers that you'd like to share with the dzone community? if so, please submit here.
check if a given string is an isbn number
write a method that will take a string parameter and check if it conforms to the isbn-13 specification as detailed in wikipedia.
the calculation of an isbn-13 check digit begins with the first 12 digits of the thirteen-digit isbn (thus excluding the check digit itself). each digit, from left to right, is alternately multiplied by 1 or 3, then those products are summed modulo 10 to give a value ranging from 0 to 9. subtracted from 10, that leaves a result from 1 to 10. a zero (0) replaces a ten (10), so, in all cases, a single check digit results.
formally, the isbn-13 check digit calculation is:
![]()
catch up on all our previous puzzlers here .
Opinions expressed by DZone contributors are their own.
Trending
-
AI Technology Is Drastically Disrupting the Background Screening Industry
-
IntelliJ IDEA Switches to JetBrains YouTrack
-
HashMap Performance Improvements in Java 8
-
How to Load Cypress Chrome Extension
Comments