DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Integrating PostgreSQL Databases with ANF: Join this workshop to learn how to create a PostgreSQL server using Instaclustr’s managed service

[DZone Research] Observability + Performance: We want to hear your experience and insights. Join us for our annual survey (enter to win $$).

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Trending

  • Lost in Communication and Collaboration
  • How To Create a Resource Chart in JavaScript
  • 6 Proven Kubernetes Deployment Best Practices for Your Projects
  • Best Practices for Writing Clean Java Code

Thursday Code Puzzler: ISBN Validator

James Sugrue user avatar by
James Sugrue
CORE ·
Apr. 04, 13 · Interview
Like (1)
Save
Tweet
Share
5.37K Views

Join the DZone community and get the full member experience.

Join For Free

thursday 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:
x_{13} = \big(10 - \big(x_1 + 3x_2 + x_3 + 3x_4 + \cdots + x_{11} + 3x_{12}\big) \,\bmod\, 10\big) \,\bmod\, 10.

catch up on all our previous puzzlers here .

Opinions expressed by DZone contributors are their own.


Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: