The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

Using Euclid's algorithm in a Fraction Class

I am trying to use Euclid's Algorithm in a fraction class. I am not finished with the class yet so there are parts that are incomplete. I am unsure of how I would use the method. Would I put in the setter methods? or Public fraction (int n, int d)?

Re: Using Euclid's algorithm in a Fraction Class

I'm not sure where you're going with this. It seems like you have a good start on it in your gcd method. You mention putting it in the setter methods or the constructor, what are you really trying to do with the algorithm? If you could give us a flow of what you're trying to accomplish it would be easier to help.