Task

Draw a Cantor set.



See details at this Wikipedia webpage:   Cantor set

 
global ancho, alto, intervalo
ancho = 81 : alto = 5
dim intervalo(alto, ancho)
 
subroutine Cantor()
	for i = 0 to alto - 1
		for j = 0 to ancho - 1
			intervalo[i, j] = "■"
		next j
	next i
end subroutine
 
subroutine ConjCantor(inicio, longitud, indice)
	segmento = longitud / 3
	if segmento = 0 then return
	for i = indice to alto - 1
		for j = inicio + segmento to inicio + segmento * 2 - 1
			intervalo[i, j] = " "
		next j
	next i
	call ConjCantor(inicio, segmento, indice + 1)
	call ConjCantor(inicio + segmento * 2, segmento, indice + 1)
end subroutine
 
call Cantor()
call ConjCantor(0, ancho, 1)
for i = 0 to alto - 1
	for j = 0 to ancho - 1
		print intervalo[i, j];
	next j
	print
next i
End
 