Math entrance exam question. Period of a function