Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import recursion.Recursion; // Uncomment this block of code to test Activity 4 /* System.out.println( Activity 4:); // Test factorial System.out.println(Factorial:); for (int ii = 1;

image text in transcribed

import recursion.Recursion;
// Uncomment this block of code to test Activity 4
/*
System.out.println(" Activity 4:");
// Test factorial
System.out.println("Factorial:");
for (int ii = 1; ii
System.out.print(Recursion.fact(ii) + " ");
}
// Test fibonacci
System.out.println(" Fibonacci:");
for (int ii = 1; ii
System.out.print(Recursion.fib(ii) + " ");
}
// Test Euclid's GCD algorithm
System.out.println(" GCD:");
System.out.println ("GCD of 96 and 60 is " + Recursion.gcd(96, 60));
System.out.println ("GCD of 30 and 10 is " + Recursion.gcd(30, 10));
System.out.println ("GCD of 96 and 120 is " + Recursion.gcd(96, 120));
// Uncomment out this block of code to test Project 4
System.out.println(" Test Project 4:");
System.out.println("Power:");
for (int ii = 1; ii
for (int jj = 0; jj
System.out.print(ii + "^" + jj + "=" + Recursion.power(ii,jj) + " ");
}
System.out.println();
}
*/
1) Download the source code from https:/lgithub.com/CGCC-CS/205activity4.git. The source code has a driver class called Activity4.java that calls the methods below. Uncomment the test code. Your recursive methods should work with the test driver without making any changes. 2) Write a recursive Java method fact (n) to find n! 3) Write a recursive Java method fib (n) that finds the nth Fibonacci number 4) Write a recursive method that gcd (num1, num2) implements the GCD algorithm defined below. You should not implement any other GCD algorithm. gcd(num1, num2) = num2 if num2

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Visual Basic 6 Databases

Authors: Charles Williams

1st Edition

1861002025, 978-1861002020

More Books

Students also viewed these Databases questions

Question

l Identify three internal sources for recruiting.

Answered: 1 week ago