Posted: Sat Nov 12, 2005 4:04 pm Post subject: (No subject)
So now you don't have to type syntax = c++ before your code, just do it inside the tags. You also don't have to double post because you can edit your posts. Even better, if you wanted to check if it works you could have used the preview button and edited your post before posting it .
Sponsor Sponsor
Geminias
Posted: Sun Nov 13, 2005 7:53 pm Post subject: (No subject)
lol, ya ya, i'm a big noob. laugh while you still can
wtd
Posted: Sun Nov 13, 2005 8:06 pm Post subject: (No subject)
We're all noobs next to someone.
md
Posted: Sun Nov 13, 2005 10:09 pm Post subject: (No subject)
I disagree! I'm a noob next to everyone! Wait...
In any case it's alright to make mistakes, so long as you learn from them
Flikerator
Posted: Tue Nov 15, 2005 3:01 pm Post subject: (No subject)
Cornflake wrote:
I disagree! I'm a noob next to everyone! Wait...
In any case it's alright to make mistakes, so long as you learn from them
Except when sky diving...Its better to learn from other peoples mistakes
bugzpodder
Posted: Tue Nov 15, 2005 6:13 pm Post subject: Re: LowestCommonMultiple
Viper wrote:
**Recursion must be used**
The LCM (lowest common multiple ) of two non-zero integers can be found using the formula: lcm(num1, num2) = num1*num2/ gcd(num1, num2) where: gcd(num1, num2) is the greatest common divisor of num1 and num2. here's the trick. the program should employ a recursive approach to finding the gcd of two number. The recursive definition is given by:
if num2 divides evenly into num1 then
gcd= num2
could someone re-write tht in C++ for me plz
here it is in turing
code:
var lcm, gcd : real := 0
var num1, num2 : int := 0
%------------------------------------------------------------------------------------------
proc starter
put "Enter the numbers you wish to find the 'LCM' for"
put "***********Hit enter after each number**********"
get num1
get num2
end starter
%------------------------------------------------------------------------------------------
proc GCD (num1, num2 : real)
if num1 mod num2 = 0 then
gcd := num2
else
GCD (num2, num1 mod num2)
end if
end GCD
%------------------------------------------------------------------------------------------
proc LCM (gcd, num1, num2 : real)
lcm := num1 * num2 / gcd
put "The 'LCM' for", " ", num1, " ", "&", " ", num2, " ", "is", " ", lcm
put "The 'GCD' for", " ", num1, " ", "&", " ", num2, " ", "is", " ", gcd
end LCM
gcd on reals? intriguing!! and I wouldnt do mod 0 if I were you. and be extra careful with negatives
MysticVegeta
Posted: Thu Jan 19, 2006 12:25 pm Post subject: (No subject)
Wow the recursive solution to the GCD and LCM using GCD is amazing.. Never thought about it really.. really neat website wtd, saving a shortcut in my programming folder.