Jump to content

Sum of the digits of n is substring of n: Difference between revisions

(added Perl programming solution)
(→‎{{header|BASIC}}: fix the bugs)
Line 43:
 
=={{header|BASIC}}==
{{incorrect|BASIC|wrong output, last should be 919<br><br>suspect I mod 10 shd be K mod 10}}
<lang basic>10 DEFINT I,J,K
20 FOR I=0 TO 999
30 J=0: K=I
40 IF K>0 THEN J=J+IK MOD 10: K=K\10: GOTO 40
5041 IF INSTR(I$=STR$(I),STR: I$=RIGHT$(J)) THEN PRINT I$,LEN(I$)-1)
42 J$=STR$(J): J$=RIGHT$(J$,LEN(J$)-1)
50 IF INSTR(I$,J$) THEN PRINT I,
60 NEXT I</lang>
{{out}}
<pre> 0 1 2 3 4
5 6 7 8 9
2110 4220 6330 8440 12450
15560 186 70 217 80 248 90 279 100
301109 311119 321129 331139 341149
351159 361169 371179 381189 391199
602200 612300 622400 632500 642600
652700 662800 672900 682910 692911
903912 913 923914 933915 943916
953917 963918 973 983 993</pre>919
</pre>
 
=={{header|C}}==
2,114

edits

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