RosettaCodeData/Task/100-doors/S-BASIC/100-doors.basic
2023-07-01 13:44:08 -04:00

27 lines
507 B
Text

$constant DOOR_OPEN = 1
$constant DOOR_CLOSED = 0
$constant MAX_DOORS = 100
var i, j = integer
dim integer doors(MAX_DOORS)
rem - all doors are initially closed
for i = 1 to MAX_DOORS
doors(i) = DOOR_CLOSED
next i
rem - cycle through at increasing intervals and flip doors
for i = 1 to MAX_DOORS
for j = i to MAX_DOORS step i
doors(j) = 1 - doors(j)
next j
next i
rem - report results
print "The open doors are:"
for i = 1 to MAX_DOORS
if doors(i) = DOOR_OPEN then
print i;
next i
end