Write a recursive method expFive(n) to compute y=5^n. For instance, if n is 0, y is 1. Ifnis 3, then y is 125. If n is 4, then y is 625. The recursive method cannot have loops. Then write a testing program to call the recursive method. If you run your program, the results should look like this: > run RecExpTest Enter a number: 125 > run RecExpTest Enter a number: 3125 For two integers m and n, their GCD(Greatest Common Divisor) can be computed by a recursive function. Write a recursive method ged(m,n) to find their Greatest Common Divisor. Once m is 0, the function returns n. Once n is 0, the function returns m. If neither is 0, the function can recursively calculate the Greatest Common Divisor with two smaller parameters: One is n, the second one is m mod n. Although there are other approaches to calculate Greatest Common Divisor, please follow the instructions in this question, otherwise you will not get the credit. Meaning your code needs to follow the given algorithm. Then write a testing program to call the recursive method. If you run your program, the results should look like this: >run RecGCDTest Enter m Enter n: 20 >run RecGCDTest Enter m 4 Enter n

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
1. Write a recursive method expFive(n) to compute y=5^n. For instance, if n is 0, y is 1. If n is 3,
then y is 125. If n is 4, then y is 625. The recursive method cannot have loops. Then write a
testing program to call the recursive method. If you run your program, the results should look like
this:
> run RecExpTest
Enter a number:
3
125
>run RecExpTest
Enter a number:
3125
2. For two integers m and n, their GCD(Greatest Common Divisor) can be computed by a
recursive function. Write a recursive method gcd(m,n) to find their Greatest Common
Divisor. Once m is 0, the function returns n. Once n is 0, the function returns m. If neither
is 0, the function can recursively calculate the Greatest Common Divisor with two
smaller parameters: One is n, the second one is m mod n. Although there are other
approaches to calculate Greatest Common Divisor, please follow the instructions in
this question, otherwise you will not get the credit. Meaning your code needs to follow
the given algorithm.
Then write a testing program to call the recursive method. If you run your program, the results
should look like this:
>run RecGCDTest
Enter m:
40
Enter n:
20
20
>run RecGCDTest
Enter m:
46
Enter n:
36
12
Transcribed Image Text:1. Write a recursive method expFive(n) to compute y=5^n. For instance, if n is 0, y is 1. If n is 3, then y is 125. If n is 4, then y is 625. The recursive method cannot have loops. Then write a testing program to call the recursive method. If you run your program, the results should look like this: > run RecExpTest Enter a number: 3 125 >run RecExpTest Enter a number: 3125 2. For two integers m and n, their GCD(Greatest Common Divisor) can be computed by a recursive function. Write a recursive method gcd(m,n) to find their Greatest Common Divisor. Once m is 0, the function returns n. Once n is 0, the function returns m. If neither is 0, the function can recursively calculate the Greatest Common Divisor with two smaller parameters: One is n, the second one is m mod n. Although there are other approaches to calculate Greatest Common Divisor, please follow the instructions in this question, otherwise you will not get the credit. Meaning your code needs to follow the given algorithm. Then write a testing program to call the recursive method. If you run your program, the results should look like this: >run RecGCDTest Enter m: 40 Enter n: 20 20 >run RecGCDTest Enter m: 46 Enter n: 36 12
Expert Solution
steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

Can you try it in java? Forgot to mention what language to use. Thank You!

Solution
Bartleby Expert
SEE SOLUTION
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY