Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Turing Program
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
mike cra




PostPosted: Wed Oct 20, 2010 7:11 pm   Post subject: Turing Program

I was able to do Permutations n combination

Anyone able to do the GCD or LCM or the Number Theory? I have no clue :S



hgh.jpg
 Description:
 Filesize:  480.55 KB
 Viewed:  106 Time(s)

hgh.jpg


Sponsor
Sponsor
Sponsor
sponsor
SNIPERDUDE




PostPosted: Wed Oct 20, 2010 10:42 pm   Post subject: RE:Turing Program

Let's tackle this one at a time then. Starting with LCM, what have you tried? What aspect are you stuck with? We can't do your homework for you, but we can help you understand whatever it is you're stuck on.
Carey




PostPosted: Thu Oct 21, 2010 6:56 pm   Post subject: RE:Turing Program

For GCD, you'll want to use recursion and Euclid's Algorithm

Example (pseudo-code, will not run):
code:

fcn gcd (a, b :int) : int
   if b is 0 then return a
   if anything else then return gcd (b, a mod b) %this is the recursive call. It will call the function from inside itself. At first it's hard to wrap your head around.
end


You can then use the GCD method in finding the LCM by following the formula here
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: