Exception handling in binomial calculation