diff options
| author | Mattias Andrée <maandree@kth.se> | 2016-07-25 17:03:54 +0200 |
|---|---|---|
| committer | Mattias Andrée <maandree@kth.se> | 2016-07-25 17:03:54 +0200 |
| commit | a5ae82e67f914d9339ac22e0c2df9fe9b79b0f57 (patch) | |
| tree | c161a106df745eae87c985a3aa64c87e978a578a /doc | |
| parent | Fix a small error in the solution for Powers of the golden ratio (diff) | |
| download | libzahl-a5ae82e67f914d9339ac22e0c2df9fe9b79b0f57.tar.gz libzahl-a5ae82e67f914d9339ac22e0c2df9fe9b79b0f57.tar.bz2 libzahl-a5ae82e67f914d9339ac22e0c2df9fe9b79b0f57.tar.xz | |
Fix another error in the solution for Powers of the golden ratio
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
| -rw-r--r-- | doc/exercises.tex | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/doc/exercises.tex b/doc/exercises.tex index 93f77e4..160067d 100644 --- a/doc/exercises.tex +++ b/doc/exercises.tex @@ -488,7 +488,7 @@ the set of pseudoprimes. \item \textbf{Powers of the golden ratio} This was an information gathering exercise. -For $n \ge 1$, $L_n = [\varphi^n]$, where +For $n \ge 2$, $L_n = [\varphi^n]$, where $L_n$ is the $n^\text{th}$ Lucas number. \( \displaystyle{ @@ -505,12 +505,14 @@ but for efficiency and briefness, we will use \vspace{-1em} \begin{alltt} -void golden_pow(z_t r, z_t p) +void golden_pow(z_t r, z_t n) \{ - if (zsignum(p) <= 0) - zsetu(r, zcmpi(p, -1) >= 0); + if (zsignum(n) <= 0) + zsetu(r, zcmpi(n, -1) >= 0); + else if (!zcmpu(n, 1)) + zsetu(r, 2); else - lucas(r, p); + lucas(r, n); \} \end{alltt} |
