java-recursion
Task: Recursion practice
Write a Java program with functions for each of the following problems. Each problem should be solved by writing a recursive function. Your final program should not have any loops in it.
All of your solutions should be in a single .java file. The main function of the file should demonstrate each of your solutions, by running several tests and producing the corresponding outputs.
Write a recursive method to
- To calculate power of a given number from user
- To multiply m by n using only repeated addition
- To reverse a String using recursion
- To return the length of a linked list using a recursive method
- To implement the Euclids algorithm using a recursive approach.
The Euclids algorithm to calculate the greatest common divisor of two positive integer numbers a and b (gcd(a,b)) is defined recursively as:
gcd(a,b) := a if a = b
gcd(a,b) := gcd(a – b, b) if a > b
gcd(a,b) := gcd(a, b – a) if b > a
Number 1-4 I have the codes, MAJORITY OF THE WORK IS DONE.