Listato per il basic del Commodore 64 che consente controllare l'esattezza del codice fiscale in Basic 2.0.
10 dim c(16),d(26)
20 fori=1to16
30 readc(i)
40 nexti
50 fori=1to26
60 readd(i)
70 next i
80 print chr$(147)
90 input"Inserire il codice fiscale";a$
100 gosub 20000
10000 print chr$(147):print "Lunghezza del codice errata":gosub30000
10010 print chr$(147):print "Codice errato":gosub30000
20000 z=1
20010 if len(a$)<>16 then goto 10000
20020 i=1
20030 b$=mid$(a$,i,1)
20040 if b$<"a" or b$>"z" then 20070
20050 if c(i)<>0 then 10010
20060 goto 20110
20070 if b$<"0" or b$>"9" then goto 10010
20080 if c(i)<>1 then 10010
20090 i=i+1
20100 if i<=16 then 20030
20110 s=0
20150 for i=1 to 15 step 2
20160 b$=mid$(a$,i+1,1)
20170 if c(i)=0 then 20200
20180 s=s+d(val(b$)+1)
20190 goto 20120
20200 s=s+d(val(b$)-64)
20210 if i=15 then 20270
20220 b$=mid$(a$,i+1,1)
20230 if c(i+1)=0 then 20260
20240 s=s+val(b$)
20250 goto 20270
20260 s=s+asc(b$)-65
20270 next i
20280 r=s-int(s/26)*26
20290 if mid$(a$,16,1)<>chr$(r+65) then 10010
20300 z=0
20400 print "Il codice";a$;"è esatto"
30000 print" Se vuoi riinserire il codice premi R"
30010 print" altrimenti un altro tasto…."
30020 get x$:if x$="" then 30020
30030 if x$="r" then run
30040 end
30100 data 0,0,0,0,0,0,1,1,0,1,1,0,1,1,1,0,1,0,5,7,9,13,15,17,19,21,2,4,18,20,11
30110 data 3,6,8,12,14,16,10,22,25,24,23
Torna indietro