Consider the following Racket code:
def f(n):
for i in range(int(n/2)):
print("!")
for i in range(n):
for j in range(n):
print("!")
print("!")
def g(n):
if n <= 1:
pass # i.e., do nothing
else:
print("!")
print("!")
print("!")
g(n-2)
Give two combinatorial descriptions for the number of !s printed by f, the first using summation notation, and the second, an explicit formula without the use of summation notation.
Your description should be a function of the input n.
Give a recurrence relation describing the number of !s printed by g.
(Hint: Your recurrence relation’s case should account for the fact that the recurrence goes down by two!)
Derive a closed-form expression for this recurrence relation and prove that the closed-form expression is equivalent to the recurrence. For this step, assume that $n$ is even.
(Hint: When proving your formula correct, note that because the recurrence ticks down by two, standard mathematical induction will not suffice.)
Adapt your answer from the previous part to account for any $n \in \mathbb{N}$.
(Hint: There are two ways to proceed. You may consider creating an additional recurrence to your solution for the case when $n$ is odd. It is also possible to come up with a single recurrence that uses the floor function $\lfloor r \rfloor$ which rounds real number $r$ down to the nearest whole number. For example $\lfloor 4.7 \rfloor = 4$.)
In the game of roulette, players bet on the outcome of a ball randomly landing in 38 distinct slots labeled with the numbers $1$–$36$, $0$, and $00$. The numbers in the range $1$–$36$ are furthermore colored as follows:
\[\begin{align*} 1, 3, 5, 7, 9, 12, 14, 16, 18, 19, 21, 23, 25, 27, 30, 32, 34, 36 &= \mathsf{red} \\ 2, 4, 6, 8, 10, 11, 13, 15, 17, 20, 22, 24, 26, 28, 29, 31, 33, 35 &= \mathsf{black} \end{align*}\]Give combinational descriptions (i.e., unsimplified formulae) for each of the required values.