The Artima Developer Community
Sponsored Link

Java Answers Forum
here is another tough cookie...

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Amber K

Posts: 6
Nickname: amberk
Registered: Mar, 2002

here is another tough cookie... Posted: Mar 10, 2002 9:35 AM
Reply to this message Reply
Advertisement
Problem type: Recursion / Java Data Structures
Problem: Given two positive integers i and j, the greatest common divisor(gcd) of i and j, written:
gcd(i,j) is the largest integer k such that (i % k = 0) and (j % k = 0) For example, gcd(35,21) = 7 and gc(8,15) = 1. Develope a recursive method that returns the gcd of i and j.
Here is the Method Description ->
//precondition: i > 0, j > 0
//postcondition: the greatest common divisor (gcd) of i and j has been returned
public int gcd (int i, int j);

Test the method with a processInput (String s) method that converts s to two positive integers and outputs their greatest common divisor.

------------------------------------------------------
A posted complete solution would be awesome! and thank you in advance!

Amber :)

Topic: dll and java Previous Topic   Next Topic Topic: How to execute commands on the client system through browsers

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use