How to resolve the algorithm Sierpinski triangle step by step in the ALGOL 68 programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Sierpinski triangle step by step in the ALGOL 68 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 ALGOL 68 programming language
Source code in the algol programming language
PROC sierpinski = (INT n)[]STRING: (
FLEX[0]STRING d := "*";
FOR i TO n DO
[UPB d * 2]STRING next;
STRING sp := " " * (2 ** (i-1));
FOR x TO UPB d DO
STRING dx = d[x];
next[x] := sp+dx+sp;
next[UPB d+x] := dx+" "+dx
OD;
d := next
OD;
d
);
printf(($gl$,sierpinski(4)))
You may also check:How to resolve the algorithm The Twelve Days of Christmas step by step in the Tcl programming language
You may also check:How to resolve the algorithm Euler method step by step in the PowerShell programming language
You may also check:How to resolve the algorithm Sierpinski triangle step by step in the COBOL programming language
You may also check:How to resolve the algorithm Program name step by step in the COBOL programming language
You may also check:How to resolve the algorithm Floyd's triangle step by step in the Icon and Unicon programming language