2
0
Fork 0
mirror of https://github.com/MartinThoma/LaTeX-examples.git synced 2025-04-26 06:48:04 +02:00
LaTeX-examples/source-code/Pseudocode/Horner-Schema/Horner-Schema.tex

43 lines
1.5 KiB
TeX
Raw Normal View History

2013-06-11 21:59:02 +02:00
\documentclass{article}
\usepackage[pdftex,active,tightpage]{preview}
\setlength\PreviewBorder{2mm}
\usepackage[utf8]{inputenc} % this is needed for umlauts
\usepackage[ngerman]{babel} % this is needed for umlauts
\usepackage[T1]{fontenc} % this is needed for correct output of umlauts in pdf
\usepackage{amssymb,amsmath,amsfonts} % nice math rendering
\usepackage{braket} % needed for \Set
\usepackage{algorithm,algpseudocode}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,calc}
\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}
\newcommand*{\AddNote}[4]{%
\begin{tikzpicture}[overlay, remember picture]
\draw [decoration={brace,amplitude=0.5em},decorate,very thick]
($(#3)!(#1.north)!($(#3)-(0,1)$)$) --
($(#3)!(#2.south)!($(#3)-(0,1)$)$)
node [align=center, text width=2.5cm, pos=0.5, anchor=west] {#4};
\end{tikzpicture}
}%
\begin{document}
\begin{preview}
\begin{algorithm}[H]
\begin{algorithmic}
\Require $Z \in \mathbb{N}_{\geq 0}, b \in \mathbb{N}_{\geq 2}$
\State $i\gets 0$
\While{$Z > 0$}
\State $y_i\gets Z \mod b$
\State $Z \gets \frac{Z - y_i}{b}$
\State $i \gets i + 1$
\EndWhile
\\
2013-08-22 22:06:19 +02:00
\State \textbf{Result:} $y_{0} y_{1} \dots y_{i-1}$
2013-06-11 21:59:02 +02:00
\end{algorithmic}
2013-08-22 22:06:19 +02:00
\caption{Horner-Schema for changing base for numbers in $\mathbb{N}_0$}
2013-06-11 21:59:02 +02:00
\label{alg:hornerschemaGanzeZahlen}
\end{algorithm}
\end{preview}
\end{document}