Jump to content

ISBN13 check digit: Difference between revisions

Added BASIC256 and Gambas
(Add EasyLang)
(Added BASIC256 and Gambas)
Line 727:
0820424528 NG length
</pre>
 
=={{header|BASIC256}}==
{{trans|Ring}}
<syntaxhighlight lang="vb">arraybase 1
dim isbn = {"978-1734314502", "978-1734314509", "978-1788399081", "978-1788399083", "978-2-74839-908-0", "978-2-74839-908-5", "978 1 86197 876 9"}
 
for n = 1 to isbn[?]
sum = 0
isbnStr = isbn[n]
isbnStr = replace(isbnStr, "-", "")
isbnStr = replace(isbnStr, " ", "")
for m = 1 to length(isbnStr)
if m mod 2 = 0 then
num = 3 * int(mid(isbnStr, m, 1))
else
num = int(mid(isbnStr, m, 1))
end if
sum += num
next m
if sum mod 10 = 0 then
print isbn[n]; ": good"
else
print isbn[n]; ": bad"
end if
next n</syntaxhighlight>
 
=={{header|BCPL}}==
Line 1,498 ⟶ 1,523:
 
In '''[https://formulae.org/?example=ISBN13_check_digit this]''' page you can see the program(s) related to this task and their results.
 
=={{header|Gambas}}==
{{trans|BASIC256}}
<syntaxhighlight lang="vbnet">Public Sub Main()
Dim isbn As String[] = ["978-1734314502", "978-1734314509", "978-1788399081", "978-1788399083", "978-2-74839-908-0", "978-2-74839-908-5", "978 1 86197 876 9"]
For n As Integer = 1 To isbn.Count
Dim sum As Integer = 0, num As Integer
Dim isbnStr As String = isbn[n]
isbnStr = Replace(isbnStr, "-", "")
isbnStr = Replace(isbnStr, " ", "")
For m As Integer = 1 To Len(isbnStr)
If m Mod 2 = 0 Then
num = 3 * CInt(Mid(isbnStr, m, 1))
Else
num = CInt(Mid(isbnStr, m, 1))
End If
sum += num
Next
If sum Mod 10 = 0 Then
Print isbn[n]; ": good"
Else
Print isbn[n]; ": bad"
End If
Next
End</syntaxhighlight>
 
=={{header|Go}}==
2,161

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.