summaryrefslogtreecommitdiff
path: root/aied2018/presentation/motivation.tex
diff options
context:
space:
mode:
authorMartin Možina <martin.mozina@fri.uni-lj.si>2018-06-19 20:52:28 +0200
committerMartin Možina <martin.mozina@fri.uni-lj.si>2018-06-19 20:52:28 +0200
commit64b0ff920ea3248d467c5eb082a213204c2d01c9 (patch)
tree82e78ca87b46c3ea55c6bd26fc53c88116218246 /aied2018/presentation/motivation.tex
parent9f338acfed58e97db36750e49ffbdadba25bd006 (diff)
Representation of rules.
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.