How to resolve the algorithm Sierpinski triangle step by step in the Run BASIC programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Sierpinski triangle step by step in the Run BASIC programming language
Table of Contents
Problem Statement
Produce an ASCII representation of a Sierpinski triangle of order N.
The Sierpinski triangle of order 4 should look like this:
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Sierpinski triangle step by step in the Run BASIC programming language
Source code in the run programming language
nOrder=4
dim xy$(40)
for i = 1 to 40
xy$(i) = " "
next i
call triangle 1, 1, nOrder
for i = 1 to 36
print xy$(i)
next i
end
SUB triangle x, y, n
IF n = 0 THEN
xy$(y) = left$(xy$(y),x-1) + "*" + mid$(xy$(y),x+1)
ELSE
n=n-1
length=2^n
call triangle x, y+length, n
call triangle x+length, y, n
call triangle x+length*2, y+length, n
END IF
END SUB
You may also check:How to resolve the algorithm Constrained random points on a circle step by step in the Fortran programming language
You may also check:How to resolve the algorithm Babbage problem step by step in the Liberty BASIC programming language
You may also check:How to resolve the algorithm Sleep step by step in the Delphi programming language
You may also check:How to resolve the algorithm Run-length encoding step by step in the Ruby programming language
You may also check:How to resolve the algorithm Primorial numbers step by step in the Pascal programming language