Have you been told to use
BigInteger? If not, you cannot fulfil your requirements because the product of all even numbers between 1 and 100 will overflow the limits of
int and
long. In fact, that calculation will return a result, both for
int and
long which I can easily predict, so you needn’t bother with the code
.
As for odd numbers, as Rob has said you are supposed to use a loop, but there is another way to calculate that which I learnt at school.