📚 The CoCalc Library - books, templates and other resources
cocalc-examples / martinthoma-latex-examples / source-code / Pseudocode / Horner-Schema / Horner-Schema.tex
132932 viewsLicense: OTHER
\documentclass{article}1\usepackage[pdftex,active,tightpage]{preview}2\setlength\PreviewBorder{2mm}34\usepackage[utf8]{inputenc} % this is needed for umlauts5\usepackage[ngerman]{babel} % this is needed for umlauts6\usepackage[T1]{fontenc} % this is needed for correct output of umlauts in pdf7\usepackage{amssymb,amsmath,amsfonts} % nice math rendering8\usepackage{braket} % needed for \Set9\usepackage{algorithm,algpseudocode}1011\usepackage{tikz}12\usetikzlibrary{decorations.pathreplacing,calc}13\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}14\newcommand*{\AddNote}[4]{%15\begin{tikzpicture}[overlay, remember picture]16\draw [decoration={brace,amplitude=0.5em},decorate,very thick]17($(#3)!(#1.north)!($(#3)-(0,1)$)$) --18($(#3)!(#2.south)!($(#3)-(0,1)$)$)19node [align=center, text width=2.5cm, pos=0.5, anchor=west] {#4};20\end{tikzpicture}21}%2223\begin{document}24\begin{preview}25\begin{algorithm}[H]26\begin{algorithmic}27\Require $Z \in \mathbb{N}_{\geq 0}, b \in \mathbb{N}_{\geq 2}$28\State $i\gets 0$29\While{$Z > 0$}30\State $y_i\gets Z \mod b$31\State $Z \gets \frac{Z - y_i}{b}$32\State $i \gets i + 1$33\EndWhile34\\35\State \textbf{Result:} $y_{0} y_{1} \dots y_{i-1}$36\end{algorithmic}37\caption{Horner-Schema for changing base for numbers in $\mathbb{N}_0$}38\label{alg:hornerschemaGanzeZahlen}39\end{algorithm}40\end{preview}41\end{document}424344