CreateBytes interview question

prime no. code with optimisation