ricky_vancouver Posted December 11, 2010 Share Posted December 11, 2010 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 More sharing options...
requinix Posted December 11, 2010 Share Posted December 11, 2010 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. Link to comment https://forums.phpfreaks.com/topic/221295-find-middle-numbervariable/#findComment-1145675 Share on other sites More sharing options...
ricky_vancouver Posted December 11, 2010 Author Share Posted December 11, 2010 thanks Link to comment https://forums.phpfreaks.com/topic/221295-find-middle-numbervariable/#findComment-1145683 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.