Showing a mapping has infinitely many solutions Problem: Define a mapping $\gamma\colon\mathbb{N}\to\mathbb{N}$ such that for each $n\in\mathbb{N}$ the equation $\gamma(x)=n$ has infinitely many solutions.
Book solution: Let $p_n$ denote the $n$th prime ($p_1=2, p_2=3, \ldots$). Define $\gamma$ by $\gamma(p_n^k)=n$ for $k=1,2,3,\ldots$; $\gamma(m)$ can then be anything for $m$ not a prime power. 
My solution: Define $\gamma$ by $\gamma(n\cdot\cos(\pi/2\cdot k))=n$ for $k=1,2,3,\ldots$. Doesn't this work? It seems like there are so many trivial ways to answer this problem correctly or am I missing something? 
$\color{red}{\text{Edit: Concerning the book's solution:}}$ Suppose $\gamma(x)=5$. Then solutions are $$p_5^k=11^k=\underbrace{11,121,\ldots}_{\text{infinitely many}},$$
where there are evidently infinitely many solutions. Is my understanding correct? 

$\newcommand{\N}[0]{\mathbb{N}}$The general recipe is to write $\N$ as the union of infinitely many infinite disjoint subsets $A_{n}$, for $n \in \N$, and then define $\gamma(x) = n$ for $x \in A_{n}$, that is, $A_{n} = \gamma^{-1}(\{ n \})$.
My favourite example, which comes from Hilbert's hotel, is to take, for $n \ge 1$
$$
A_{n} = \{ x \in \N : x \equiv 2^{n-1} \pmod{2^{n}} \},
$$
So $A_{1}$ are the odd numbers, $A_{2}$ are the numbers congruent to $2$ modulo $4$, etc
