public class Summation { // Main method. public static void main(String[] args) { for (String s: args) { try { int n = Integer.parseInt(s); int x = fibonacci(n); System.out.println(x); } catch(NumberFormatException e) { System.out.println("The input is not a number."); } } } // Summation from 0 to N public static int sum(int n) { int x = 0; for(int i = 0;i <= n;i++) { x = x + i; } return x; } // Recursive function for finding the Nth Fibonacci number. public static int fibonacci(int n) { int x = 0; if (n == 0) { x = 0; } else if (n == 1) { x = 1; } else { x = fibonacci((n-1)) + fibonacci((n-2)); } return x; } }