Jump to content

Damm algorithm: Difference between revisions

Add BASIC
m (Added Delphi reference to Pascal code)
(Add BASIC)
Line 366:
F 5727
T 112946</pre>
 
=={{header|BASIC}}==
 
<lang basic>10 DEFINT D,I,X,Y: DIM DT(9,9)
20 FOR Y=0 TO 9: FOR X=0 TO 9: READ DT(X,Y): NEXT X,Y
30 INPUT N$: IF N$="" THEN END
40 D=0
50 FOR I=1 TO LEN(N$): D=DT(VAL(MID$(N$,I,1)),D): NEXT I
60 IF D THEN PRINT "FAIL" ELSE PRINT "PASS"
70 GOTO 30
100 DATA 0,3,1,7,5,9,8,6,4,2
110 DATA 7,0,9,2,1,5,4,8,6,3
120 DATA 4,2,0,6,8,7,1,3,5,9
130 DATA 1,7,5,0,9,8,3,4,2,6
140 DATA 6,1,2,3,0,4,5,9,7,8
150 DATA 3,6,7,4,2,0,9,5,8,1
160 DATA 5,8,6,9,7,2,0,1,3,4
170 DATA 8,9,4,5,3,6,2,0,1,7
180 DATA 9,4,3,8,6,1,7,2,0,5
190 DATA 2,5,8,1,4,3,6,7,9,0</lang>
 
{{out}}
 
<pre>? 5724
PASS
? 5727
FAIL
? 112946
PASS
? 112949
FAIL
</pre>
 
=={{header|C}}==
2,124

edits

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