import java.util.Scanner;

public class Factorial {
   private static long factorial(int num) throws NegativeNumberException {
       if (num < 0)
           throw new NegativeNumberException();
           
       if(num == 0)
           return 1;

       else
           return num * factorial(num - 1);
   }

   public static void main(String[] args) {
       Scanner scanner = new Scanner(System.in);
       boolean wrongInput = true;

       while (wrongInput) {
           System.out.print("Enter n = ");
           int input = Integer.parseInt(scanner.nextLine());
           try {
               long result = factorial(input);
               System.out.print("n! = " + result);
               wrongInput = false;
           } catch (NegativeNumberException nne) {
               nne.what();
           }
       }
   }
}

@@ -302,16 +302,196 @@
 1);%0A   %7D
+%0A   %0A   private static int findSum(int%5B%5D arr, int index) %7B%0A       if (index == arr.length) %7B%0A           return 0;%0A       %7D%0A       return arr%5Bindex%5D + findSum(arr, index + 1);%0A    %7D
 %0A%0A   pub
@@ -994,15 +994,127 @@
       %7D%0A
+      %0A       int%5B%5D arr = %7B 1, 2, 3 %7D;%0A       int sum = findSum(arr, 0);%0A       System.out.printf(%22%25n%25d%22, sum);%0A
    %7D%0A%7D%0A

Update Factorial.java