1. Welcome! Please take a few seconds to create your free account to post threads, make some friends, remove a few ads while surfing and much more. ClutchFans has been bringing fans together to talk Houston Sports since 1996. Join us!

Euclid's Algorithm program

Discussion in 'BBS Hangout' started by SLrocket, Sep 30, 2007.

  1. SLrocket

    SLrocket Contributing Member

    Joined:
    Oct 9, 2006
    Messages:
    1,041
    Likes Received:
    0
    i need help on making a GCF/LCM program for a lab due on tuesday. it has to somehow utilize loops(do/while and possibly if/then-else statements) and modulating. im really confused about how to go and do this, so i came here to look for help :p
     
  2. LegendZ3

    LegendZ3 Member

    Joined:
    Nov 6, 2002
    Messages:
    4,196
    Likes Received:
    5
  3. SLrocket

    SLrocket Contributing Member

    Joined:
    Oct 9, 2006
    Messages:
    1,041
    Likes Received:
    0
    still confused as to how the program will be structured :confused:
     
  4. Mango

    Mango Member

    Joined:
    Sep 23, 1999
    Messages:
    10,189
    Likes Received:
    5,637
    What computer language will you be using?

    What is the extent of your coding ability?
     
  5. SLrocket

    SLrocket Contributing Member

    Joined:
    Oct 9, 2006
    Messages:
    1,041
    Likes Received:
    0
    java, beginner
     
  6. LegendZ3

    LegendZ3 Member

    Joined:
    Nov 6, 2002
    Messages:
    4,196
    Likes Received:
    5
    Code:
    public class GCF
    {
    	
    	public static int Euclidean(int a, int b)
    	{
    	    while(b != 0)
    	    {
    	     
    	        if (a > b)
    	            a = a - b;
    	        else
    	            b = b - a;
    	    }
    		return a;
    	}
    	
    	public static void main(String args [])
    	{
    		System.out.println("The GFC of 5 and 6 is " + Euclidean(5, 6));
    	}
    }
    
    something like this?
     
  7. SLrocket

    SLrocket Contributing Member

    Joined:
    Oct 9, 2006
    Messages:
    1,041
    Likes Received:
    0
    hmm looks like i can get it from my friend because ive saved his ass on HW assignments quite a few times lol. but i dont think i could use that because even though it may work, we havent learned the direct way of using 'Euclidean' to get it.
     

Share This Page

  • About ClutchFans

    Since 1996, ClutchFans has been loud and proud covering the Houston Rockets, helping set an industry standard for team fan sites. The forums have been a home for Houston sports fans as well as basketball fanatics around the globe.

  • Support ClutchFans!

    If you find that ClutchFans is a valuable resource for you, please consider becoming a Supporting Member. Supporting Members can upload photos and attachments directly to their posts, customize their user title and more. Gold Supporters see zero ads!


    Upgrade Now