ISBN13 check digit: Difference between revisions

no edit summary
No edit summary
Line 108:
978-1788399083: bad
</pre>
 
=={{header|Julia}}==
<lang julia>isbncheck(str) = sum(iseven(i) ? 3 * parse(Int, ch) : parse(Int, ch)
for (i, ch) in enumerate(replace(str, r"\D" => ""))) % 10 == 0
 
const testingcodes = ["978-1734314502", "978-1734314509",
"978-1788399081", "978-1788399083"]
 
for code in testingcodes
println(code, ": ", isbncheck(code) ? "good" : "bad")
end
</lang>{{out}}
<pre>
978-1734314502: good
978-1734314509: bad
978-1788399081: good
978-1788399083: bad
</pre>
 
 
=={{header|langur}}==
4,108

edits