Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

📚 The CoCalc Library - books, templates and other resources

132939 views
License: OTHER
1
\documentclass[a5paper]{article}
2
3
\usepackage{algorithm,algpseudocode}
4
\usepackage{caption}
5
6
\begin{document}
7
8
\begin{algorithm}
9
\caption{My algorithm}
10
\begin{algorithmic}[1]
11
\Procedure{Euclid}{$a,b$}\Comment{The g.c.d. of a and b}
12
\State $r\gets a\bmod b$
13
\While{$r\not=0$}\Comment{We have the answer if r is 0}
14
\State $a\gets b$
15
\State $b\gets r$
16
17
\algstore{myalg}
18
\end{algorithmic}
19
\end{algorithm}
20
21
\clearpage
22
23
\begin{algorithm}
24
\ContinuedFloat
25
\caption{My algorithm (continued)}
26
\begin{algorithmic}
27
\algrestore{myalg}
28
29
\State $r\gets a\bmod b$
30
\EndWhile\label{euclidendwhile}
31
\State \textbf{return} $b$\Comment{The gcd is b}
32
\EndProcedure
33
\end{algorithmic}
34
\end{algorithm}
35
36
\end{document}
37
38