Welcome to Dream.In.Code
Become a Java Expert!

Join 149,602 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,900 people online right now. Registration is fast and FREE... Join Now!




GCF equation

 
Reply to this topicStart new topic

GCF equation, I semi-understand not fully

Mastergeek666
17 Sep, 2007 - 09:22 AM
Post #1

D.I.C Head
Group Icon

Joined: 10 Aug, 2007
Posts: 120


Dream Kudos: 75
My Contributions
Hey guys I semi-understand the following equation to abtain the Greatest Common Factor, GCF, but could anyone esle shed some light so that I may further understand it and be able to explain it to others.
User is offlineProfile CardPM
+Quote Post

1lacca
RE: GCF Equation
17 Sep, 2007 - 09:40 AM
Post #2

code.rascal
Group Icon

Joined: 11 Aug, 2005
Posts: 3,822



Thanked: 12 times
My Contributions
Maybe if you tried to write down what you understand so far, it would help you better understand it in general. Just an idea...
User is offlineProfile CardPM
+Quote Post

Mastergeek666
RE: GCF Equation
17 Sep, 2007 - 09:41 AM
Post #3

D.I.C Head
Group Icon

Joined: 10 Aug, 2007
Posts: 120


Dream Kudos: 75
My Contributions
QUOTE(1lacca @ 17 Sep, 2007 - 10:40 AM) *

Maybe if you tried to write down what you understand so far, it would help you better understand it in general. Just an idea...


Sorry its just that I hardly understand the equation enough to be able to help you help me. Sorry again I just know that it somehow works.
User is offlineProfile CardPM
+Quote Post

Programmist
RE: GCF Equation
17 Sep, 2007 - 10:20 AM
Post #4

Four-letter word
Group Icon

Joined: 2 Jan, 2006
Posts: 1,250



Thanked: 11 times
Dream Kudos: 100
Expert In: Java

My Contributions
Maybe you should review what GCF is:
http://en.wikipedia.org/wiki/Greatest_common_divisor
User is offlineProfile CardPM
+Quote Post

Mastergeek666
RE: GCF Equation
17 Sep, 2007 - 06:33 PM
Post #5

D.I.C Head
Group Icon

Joined: 10 Aug, 2007
Posts: 120


Dream Kudos: 75
My Contributions
QUOTE(Programmist @ 17 Sep, 2007 - 11:20 AM) *

Maybe you should review what GCF is:
http://en.wikipedia.org/wiki/Greatest_common_divisor


I see what your getting at but that link just tells me how it works out in math. I'm asking how it works in java. For example, why is third = second and second = first%second.
CODE

     public static int GCF(int First, int Second)
     {
        int Third;
        while (Second != 0)
        {
             Third = Second;
            Second = First%Second;
             First = Third;
           }
           return First;    
     }


This post has been edited by Mastergeek666: 17 Sep, 2007 - 06:34 PM
User is offlineProfile CardPM
+Quote Post

1lacca
RE: GCF Equation
17 Sep, 2007 - 08:33 PM
Post #6

code.rascal
Group Icon

Joined: 11 Aug, 2005
Posts: 3,822



Thanked: 12 times
My Contributions
So how did you expect us to know that you were thinking of this implementation?
Anyway, until you write down what do you know (about the theory in use here and the Eucledian alg), we can't help you. If we give you explanations/facts you already know, or something that is way over your knowledge we are just wasting our time. However if we can link the knowledge you have with the implementation it might work out.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 11:51PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month