ISBN13 check digit: Difference between revisions
Content added Content deleted
Jazzedpineda (talk | contribs) (Add EasyLang) |
(Added BASIC256 and Gambas) |
||
Line 727: | Line 727: | ||
0820424528 NG length |
0820424528 NG length |
||
</pre> |
</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}}== |
=={{header|BCPL}}== |
||
Line 1,498: | Line 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. |
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}}== |
=={{header|Go}}== |