I want to define a function so that even numbers will go somewhere and odd numbers will go somewhere else. How would I get LaTeX to do the curly bracket needed, one that has two rows?

What I want to do is $\displaystyle g_n:= \displaystyle \begin{cases} n & x \in E_i \mbox{ for at least } n \mbox{ values of } i \in \mathbb{N} \\ 0 & \mbox{ otherwise} \end{cases}$ which looks fine. However...I can't put it in my document! It doesn't like the "&"s, and does nothing if I take them out...It's in a "\newtheorem{answer}{Answer}...\begin{answer}...\e nd{answer}" thingy if that makes any difference?

Help?