\documentclass[final]{article}

\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[finnish]{babel}
\usepackage{amsthm, amsfonts, amsmath, graphicx, asymptote}
\usepackage[vcentering,dvips]{geometry}
\geometry{papersize={400mm,330mm},total={400mm,330mm}}


\begin{document}

\begin{figure}[!hb]
\begin{center}
\begin{asy}
real recursion=0.2;
real kulma=aCos(1.0/sqrt(1+4*recursion^2));
real length=400.0;
int counter=17;

real sign(real operandi){
if(operandi<0){
return -1.0;
}else{
return 1.0;
}
}

void draw_triangle(int depth, pair A, pair B){
if(depth>counter){
draw(A--B);
return;
}
draw_triangle(depth+1, A, A+length*(sqrt(0.25+recursion^2)^depth)*dir(kulma+sign(B.y-A.y)*aCos((B.x-A.x)/length(A-B))));
draw_triangle(depth+1, A+length*(sqrt(0.25+recursion^2)^depth)*dir(kulma+sign(B.y-A.y)*aCos((B.x-A.x)/length(A-B))), B);
}

draw_triangle(1, (0,0),(length,0));
\end{asy}
\end{center}
\caption{Rekursioparametri 0.2, rekursiosyvyys 17.}
\end{figure}

\end{document}
