Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Lab 13 (Recursion) 1. Write a method to compute the factorial of an integer n using iteration (n! = 1 * 2 * ...
Lab 13 (Recursion) 1. Write a method to compute the factorial of an integer n using iteration (n! = 1 * 2 * ... * n) and test it. Note that you should use a long to store the computed result, and return a long (due to possible overflow issues past 13!) 2. Write a recursive method to compute the following series: m(i) 1 1/2 + 1/3 + .. + 1/i Write a test program that displays the value of m(i) for values of i between 1 and 10 (inclusive). 3. Write a recursive method that recursively adds up the digits in an integer. Use the following header: public static int sumDigits (long n). For example, sumDigits (234) would return 9 (because 2+3+4 = 9). Write a test program that reads in a number from the user and prints the sum of its digits. 4. Write a recursive method that takes an integer argument and prints the digits of that integer in reverse order on the console. For example, given the input 12345, the method would print out 54321. Use the following method header: public static void reverseDisplay (int value) 5. Write a recursive method that computes and returns the reverse of an integer (the reverse of an integer is a new integer that contains all the digits of the original, but in reverse order). For example, reverse (12345) returns 54321.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started