input geom2d;
warningcheck:=0;
angleArbre = Pi/5;

vardef ArbrePythagore(expr A,B,n)=
    save C,D,E;
    numeric C,D,E;
    D = SimilitudeACentre(A,B,-Pi/2,1);
    C = SimilitudeACentre(B,A,Pi/2,1);
    colorieAvecTransparence(Polygone(A,B,C,D), DarkBlue,0.4);
    if(n>0):
        E = SimilitudeACentre(C,D,angleArbre,cos(angleArbre));
        ArbrePythagore(D,E,n-1);
        ArbrePythagore(E,C,n-1);
    fi
enddef;

beginfig(1);

A = Point(0,0);
B = Point(1,0);

ArbrePythagore(A,B,10);

endfig;
end.