RosettaCodeData/Task/Sierpinski-carpet/BASIC256/sierpinski-carpet.basic
2023-07-01 13:44:08 -04:00

25 lines
406 B
Text

function in_carpet(x, y)
while x <> 0 and y <> 0
if(x mod 3) = 1 and (y mod 3) = 1 then return False
y = int(y / 3): x = int(x / 3)
end while
return True
end function
Subroutine carpet(n)
k = (3^n)-1
for i = 0 to k
for j = 0 to k
if in_carpet(i, j) then print("#"); else print(" ");
next j
print
next i
end subroutine
for k = 0 to 3
print "N = "; k
call carpet(k)
print
next k
end