Files
clean-sheets/template/main.typ
T

63 lines
1.2 KiB
Typst

#import "@preview/clean-sheets:0.3.0": base-template, ex_box, qed
#let logo = box(
width: 2.4cm,
height: 1cm,
stroke: 0.8pt + eastern,
radius: 3pt,
align(center + horizon, text(fill: eastern, weight: "bold")[LOGO]),
)
#show: body => base-template(
1,
[Introduction to Examples],
[Prof. Ada Example],
[Dr. Alan Assistant],
3,
([Jane Doe], [John Doe]),
[Taylor Tutor],
logo: logo,
show-end-message: true,
end-message: [Typeset with #link("https://typst.app")[Typst].],
body,
)
= Exercise 1
#ex_box(
heading: [Warm-up],
points: [10 points],
)[
Prove the following identity for every natural number $n$:
$
sum_(k=1)^n k = (n (n + 1)) / 2.
$
]
Proof by induction. #qed
= Exercise 2
#ex_box(points: [15 points])[
Implement a function that returns the first $n$ Fibonacci numbers.
]
```python
def fibonacci(n: int) -> list[int]:
"""
Returns the first n Fibonacci numbers.
"""
if n <= 0:
return []
values = [0, 1]
while len(values) < n:
values.append(values[-1] + values[-2])
return values[:n]
```
= Exercise 3
#ex_box(heading: [Discussion])[
Compare the iterative and recursive solutions.
]