Implementation of Factorial Algorithm in Java