summaryrefslogtreecommitdiff
path: root/aied2018/presentation/motivation.tex
diff options
context:
space:
mode:
Diffstat (limited to 'aied2018/presentation/motivation.tex')
-rw-r--r--aied2018/presentation/motivation.tex13
1 files changed, 7 insertions, 6 deletions
diff --git a/aied2018/presentation/motivation.tex b/aied2018/presentation/motivation.tex
index 785bd6e..69db435 100644
--- a/aied2018/presentation/motivation.tex
+++ b/aied2018/presentation/motivation.tex
@@ -1,12 +1,13 @@
- What is wrong with the following program that prints all divisors?
+ What is wrong with the following Python program that prints all divisors?
\begin{columns}
\begin{column}{0.50\textwidth}
\begin{Verbatim}
- \textbf{def} divisors(n):
- \textbf{for} d \textbf{in} range(1, \red{n}):
- \textbf{if} n % d == 0:
- \textbf{print}(d)
-\end{Verbatim}
+\textbf{def} divisors(n):
+ \textbf{for} d \textbf{in} range(1, \red{n}):
+ \textbf{if} n % d == 0:
+ \textbf{print}(d)
+\end{Verbatim}
+
\end{column}
\begin{column} {0.50\textwidth}
Answer: \texttt{range(1,n)} generates values up to \texttt{n-1}, so \texttt{n} is not printed. Instead, \texttt{range(1,n+1)} is better.