Jump to content

Sierpinski triangle/Graphical: Difference between revisions

→‎{{header|Perl}}: adding PARI/GP script
No edit summary
(→‎{{header|Perl}}: adding PARI/GP script)
Line 1,013:
run with:
ocaml graphics.cma sierpinski.ml
 
=={{header|PARI/GP}}==
{{Works with|PARI/GP|2.7.4 and above}}
[[File:SierpT9.png|right|thumb|Output SierpT9.png]]
 
<lang parigp>
\\ Sierpinski triangle fractal
\\ Note: plotmat() can be found here on
\\ http://rosettacode.org/wiki/Brownian_tree#PARI.2FGP page.
\\ 6/3/16 aev
pSierpinskiT(n)={
my(sz=2^n,M=matrix(sz,sz),x,y);
for(y=1,sz, for(x=1,sz, if(!bitand(x,y),M[x,y]=1);));\\fends
plotmat(M);
}
{\\ Test:
pSierpinskiT(9); \\ SierpT9.png
}
</lang>
{{Output}}
 
<pre>
> pSierpinskiT(9); \\ SierpT9.png
*** matrix(512x512) 19682 DOTS
</pre>
 
=={{header|Perl}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.