Jump to content

find-middle-number/variable


ricky_vancouver

Recommended Posts

I'm a newbie taking a class working on this problem.  Which I've got up until the last part.

 

I've got a form with 3 fields; all numbers.  So, I type in 3 numbers and then the form is sent to a php page.  Here's where my issue comes in;  using a loop, I need to calculate the least comon denominator between the middle number and largest number. 

 

I know how to get the largest number; $largestNum = (max($num1, $num2, $num3));

 

Where I'm stumped is how to get the middle number.

I think I know the logic but can't figure out how to implement it.

 

Here's what I think I need to do:

Create a While loop that finds the largest and smallest variables, and then use the one that is NOT them.  Then make it a variable and multiply it times the max value ($largestNUm from above).

 

Am I on the right track?

 

Thanks!

 

 

Link to comment
https://forums.phpfreaks.com/topic/221295-find-middle-numbervariable/
Share on other sites

A while loop? You're vastly overcomplicating the issue.

 

Think outside the box.

 

 

Then make it a variable and multiply it times the max value ($largestNUm from above).

That's not necessarily the LCM of the two. There's one more step.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.