Question: Need help to identify the error in my code. Initially was only using int but am trying to change to BigInteger so that I can

 Need help to identify the error in my code. Initially was

Need help to identify the error in my code. Initially was only using int but am trying to change to BigInteger so that I can calculate factorials higher than 12!

BigInteger value; 1/ Check that there is a command line parameter if (args. length == 1) { !! Get the corresponding integer or use 7 if the string is badly // formatted try { 11 Convert the first parameter to an integer value = BigInteger( args[]); } catch (Exception e) { // If anything goes wrong, use 7 System.err.printin ("The integer wasn't recognized, using 7"); value = BigInteger.valueOf(7); } } else // There's not one parameter { System.err.println("You need one command line parameter, using 7."); value = BigInteger valueof(7); } BigInteger result = fact (value); System.out.println (value + "!=" + result); } private static BigInteger fact (int n) { BigInteger product = BigInteger.ONE; for (int i = 2; i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!