Sadly, both the suggestions from Joseph544310 contain errors. The for loop has a comma rather than a semicolon. But more importantly the while loops never terminate.
It would be possible to remedy one of the latter suggestions by using if (i%2) to verify whether or not the number is odd, but this method would not be my first choice.