Question: Write a recursive function called sum(n) that computes the sum of the integers from 1 to n. Hint: recall the recursive function fact(n) in the
Write a recursive function called sum(n) that computes the sum of the integers from 1 to n. Hint: recall the recursive function fact(n) in the class Factorial discussed in lecture and posted on the webpage. Modify your answer so as

to recursively compute the sum of the integers from n to m, where n m. (If n>m, return 0.)
1/ Factorial.java public class Factorial public static int fact(int n) if(n0) // what if the return n*fact(n-1); test was n!=0 ? else return 1 public static void main(String[] args) t System.out.println(fact(10))
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
