University of Iowa Computer Science Department

Project 10 - THE LAST ONE!

Due Tuesday, May 2

1. Design and implement a program that implements Euclid's algorithm for finding the greatest common divisor of two positive integers. The greatest common divisor is the largest integer that divides both values without producing a remainder. In a class called DivsorCalc, define a static method called Gcd that accepts two integers, num1 and num2. Create a test program to test your implementation. The recursive algorithm is defined as follows:

A) Gcd(num1, num2) is num2 if num2 <= num1 and num2 divides num1 evenly (i.e., with no remainder)
B) Gcd(num1, num2) is Gcd(num2, num1) if num1 < num2
C) Gcd(num1, num2) is Gcd(num2, num1 % num2) otherwise

2. Write a recursive method named Reverse that takes a string argument and produces a string that is the reverse of the argument as the result. For instance, Reverse("abc") should produce the string "cba".
UI CLAS CRA ACM Valid CSS! Valid XHTML 1.0 Transitional Level Double-A conformance icon, W3C-WAI Web Content Accessibility Guidelines 1.0 Cynthia tested
| Modified: .