Factored out factorial to Util.java.