Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- \documentclass{article}
- \usepackage{tikz}
- \makeatletter
- \pgfmathdeclarefunction*{gcd}{2}{%
- \begingroup
- \pgfmathcontinuelooptrue
- \pgfmath@xa=#1pt\relax % <-
- \pgfmath@xb=#2pt\relax % <-
- \ifdim\pgfmath@xa=0pt\relax
- \pgfmathcontinueloopfalse
- \pgfmath@xa=\pgfmath@xb
- \fi
- \ifdim\pgfmath@xb=0pt\relax
- \pgfmathcontinueloopfalse
- \pgfmath@xb=\pgfmath@xa
- \fi
- \ifdim\pgfmath@xa<0pt\relax
- \pgfmath@xa=-\pgfmath@xa
- \fi
- \ifdim\pgfmath@xb<0pt\relax
- \pgfmath@xb=-\pgfmath@xb
- \fi
- \loop
- \ifpgfmathcontinueloop
- \ifdim\pgfmath@xa=\pgfmath@xb
- \pgfmathcontinueloopfalse
- \else
- \ifdim\pgfmath@xa>\pgfmath@xb
- \advance\pgfmath@xa by-\pgfmath@xb\relax
- \else
- \advance\pgfmath@xb by-\pgfmath@xa\relax
- \fi
- \fi
- \repeat
- \pgfmathparse{int(\pgfmath@xa)}%
- \pgfmath@smuggleone\pgfmathresult
- \endgroup}
- \makeatother
- \begin{document}
- \begin{center}
- \begin{tikzpicture}[scale=8]
- \draw [-stealth] (-0.1,0) -- (1.1,0);
- \draw [-stealth] (0,-0.1) -- (0,0.6);
- \foreach \X in {1,...,7}
- {\ifnum\X=1
- \else
- \draw (0.02,1/\X) -- (-0.02,1/\X) node[left,xshift={(-(1+pow(-1,\X)))*3pt}]{$\frac{1}{\X}$};
- \fi
- }
- \foreach \X [evaluate=\X as \Ymax using {int(\X-1)}]in {95,94,...,2}%Το μέγεθος του πρώτου όρου καθορίζει το πλήθος των κουκκίδων, άρα και την απόσταση του «τριγώνου» από τον χ'χ.
- {\foreach \Y in {1,...,\Ymax}
- {\ifnum\X<6
- \draw (\Y/\X,0.02) -- (\Y/\X,-0.02) node[below,fill=white]{$\frac{\Y}{\X}$};
- \else
- \draw[ultra thin] (\Y/\X,0.01) -- (\Y/\X,-0.01);
- \fi
- \pgfmathtruncatemacro{\TST}{gcd(\X,\Y)}
- \ifnum\TST=1
- \fill ({\Y/\X},1/\X) circle(0.05pt); %μέγεθος κουκκίδων
- \fi
- }
- }
- \foreach \X in {0,1,...,80}
- {\fill (\X/80,0) circle(0.05pt); } %μέγεθος κουκκίδων
- \end{tikzpicture}
- \end{center}
- \end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement