RosettaCodeData/Task/Eban-numbers/Chipmunk-Basic/eban-numbers.basic

43 lines
1.2 KiB
Plaintext

100 cls
110 t0 = timer
120 eban(2,1000,1)
130 eban(1000,4000,1)
140 eban(2,10000,0)
150 eban(2,100000,0)
160 eban(2,1000000,0)
170 eban(2,10000000,0)
180 eban(2,100000000,0)
190 print "Run time: ";(timer-t0);"seconds."
200 end
210 sub eban(start,ended,printable)
220 contar = 0
230 if start = 2 then
240 print "eban numbers up to and including ";ended;":"
250 else
260 print "eban numbers between ";start;"and ";ended;"(inclusive):"
270 endif
280 for i = start to ended step 2
290 b = int(i/1000000000)
300 r = (i mod 1000000000)
310 m = int(r/1000000)
320 r = (i mod 1000000)
330 t = int(r/1000)
340 r = (r mod 1000)
350 if m >= 30 and m <= 66 then m = (m mod 10)
360 if t >= 30 and t <= 66 then t = (t mod 10)
370 if r >= 30 and r <= 66 then r = (r mod 10)
380 if b = 0 or b = 2 or b = 4 or b = 6 then
390 if m = 0 or m = 2 or m = 4 or m = 6 then
400 if t = 0 or t = 2 or t = 4 or t = 6 then
410 if r = 0 or r = 2 or r = 4 or r = 6 then
420 if printable then print i;
430 contar = contar+1
440 endif
450 endif
460 endif
470 endif
480 next i
490 if printable then print
500 print "count = ";contar;chr$(10)
510 end sub