Gapful numbers: Difference between revisions

(→‎{{header|Commodore BASIC}}: Add implementation)
Line 662:
1000000032
</pre>
 
=={{header|Commodore BASIC}}==
{{trans|Clojure}}
 
Numbers >= 1,000,000,000 are printed out in scientific notation and we can't see what they actually are, so I used 100,000,000 instead.
 
<lang basic>100 DEF FNFD(N) = VAL(MID$(STR$(N),2,1))
110 DEF FNLD(N) = N - 10 * INT(N/10)
120 DEF FNBE(N) = 10 * FNFD(N) + FNLD(N)
130 DEF FNGF(N) = (N >= 100) AND (N - FNBE(N)*INT(N/FNBE(N)) = 0)
140 READ S:IF S<0 THEN 260
150 READ C
160 PRINT"THE FIRST"C"GAPFUL NUMBERS >="S":"
170 I=S:F=0
180 IF NOT FNGF(I) THEN 220
190 PRINT I,
200 F=F+1
210 IF F>=C THEN 240
220 I=I+1
230 GOTO 180
240 PRINT:PRINT
250 GOTO 140
260 END
270 DATA 1,30, 1000000,15, 100000000,10
280 DATA -1</lang>
 
{{Out}}
<pre>THE FIRST 30 GAPFUL NUMBERS >= 1 :
100 105 108 110
120 121 130 132
135 140 143 150
154 160 165 170
176 180 187 190
192 195 198 200
220 225 231 240
242 253
 
THE FIRST 15 GAPFUL NUMBERS >= 1000000 :
 
1000000 1000005 1000008 1000010
1000016 1000020 1000021 1000030
1000032 1000034 1000035 1000040
1000050 1000060 1000065
 
THE FIRST 10 GAPFUL NUMBERS >= 100000000 :
100000000 100000005
100000008 100000010
100000016 100000020
100000021 100000030
100000032 100000035</pre>
 
=={{header|Common Lisp}}==
1,480

edits