Question: public class RecModule { public static int fac(int n) { //TODO: COMPLETE BODY return 0; } public static boolean isPalindrome(String s) { //TODO : COMPLETE
public class RecModule { public static int fac(int n) { //TODO: COMPLETE BODY return 0; } public static boolean isPalindrome(String s) { //TODO : COMPLETE BODY return false; } public static double pow(double x, int n) { //TODO: COMPLETE BODY return 0; } public static int sum(int n) { //TODO : COMPLETE BODY return 0; } } Task Lists
1. Complete the body for the recursive method fac(n) which computes n! (n factorial) for n >= 0. Note: n! = n(n - 1) (n - 2) (n - 2) (2) (1), where n > 0 and zero factorial, 0! = 1.
2. Complete the body for the recursive method sum(n) to compute the sum of the first n positive integers.
3. Complete the body for the recursive method pow(x,n) for computing x^n, for a positive integer n, and real number x.
4. Complete the body for the recursive method isPalindrome(str) to determine if a string of text is a palindrome. This method accepts a String and returns true if the string reads the same forwards as backwards. The string is trivially true for empty or one(1) letter strings. Hint: You should make use of the substring and charAt methods of the String.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
