Allan- Posted September 12, 2008 Share Posted September 12, 2008 I have to check that $number1 is divisible by $number2. How? When its on divisible, then I have to display the answer in fraction. If I have to divide 9 / 21, I have to disaplay it as a fraction, then how can I find the same multipliers they have (in this case they both are divisible by 3) and make the numbers of the fraction small as possible. I hope that you understand my problem Link to comment https://forums.phpfreaks.com/topic/123980-solved-maths/ Share on other sites More sharing options...
kenrbnsn Posted September 12, 2008 Share Posted September 12, 2008 This sounds like a homework assignment. We don't do homework assignments here. Ken Link to comment https://forums.phpfreaks.com/topic/123980-solved-maths/#findComment-640024 Share on other sites More sharing options...
The Little Guy Posted September 12, 2008 Share Posted September 12, 2008 function divisibility($num1, $num2){ switch($num1){ case 9: $total = $num1 + $num2; return $total % 9; break; } } echo divisibility(9,21); http://mathforum.org/k12/mathtips/division.tips.html Link to comment https://forums.phpfreaks.com/topic/123980-solved-maths/#findComment-640027 Share on other sites More sharing options...
BlueSkyIS Posted September 12, 2008 Share Posted September 12, 2008 This sounds like a homework assignment. We don't do homework assignments here. Ken until now. Link to comment https://forums.phpfreaks.com/topic/123980-solved-maths/#findComment-640028 Share on other sites More sharing options...
sasa Posted September 12, 2008 Share Posted September 12, 2008 try <?php function gcd($a,$b){ while ($c = $a % $b){ $a = $b; $b = $c; } return $b; } echo gcd(4,6); ?> Link to comment https://forums.phpfreaks.com/topic/123980-solved-maths/#findComment-640030 Share on other sites More sharing options...
Maq Posted September 12, 2008 Share Posted September 12, 2008 I have to check that $number1 is divisible by $number2. How? fmod ($dividend ,$divisor); Returns the remainder, if 0, it's obviously divisible. Link to comment https://forums.phpfreaks.com/topic/123980-solved-maths/#findComment-640032 Share on other sites More sharing options...
Allan- Posted September 12, 2008 Author Share Posted September 12, 2008 its not homework, but i'll make this on my own. at least i'll try. Link to comment https://forums.phpfreaks.com/topic/123980-solved-maths/#findComment-640033 Share on other sites More sharing options...
Maq Posted September 13, 2008 Share Posted September 13, 2008 Have you got it to work, or at least attempted to solve this? If so, post your code again... Link to comment https://forums.phpfreaks.com/topic/123980-solved-maths/#findComment-640316 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.