Luhn test of credit card numbers: Difference between revisions
m
→{{header|Batch File}}: added good practice
Simple9371 (talk | contribs) m (→{{header|Batch File}}: added good practice) |
|||
Line 1,201:
<lang dos>@echo off
setlocal enabledelayedexpansion
call :luhn 49927398716
call :luhn 49927398717
Line 1,207:
call :luhn 1234567812345670
exit /b 0
:luhn
set "input=%1"
set "cnt=0"
set "s1=0
set "s2=0"
:digit_loop
set /a "twice=!input:~%cnt%,1!*2"
) else (
set /a
▲ if !twice! geq 10 (
▲ set /a s2+=!twice:~0,1!+!twice:~1,1!
▲ ) else (
)
)
▲ )
)
{{Out}}
<pre>>luhn.bat
|