find the maximum i & j, but not exceed amount , any ideas?
Code: Select all
$amount = 20000;
$max_area = 1000;
for ($i=0; $i<=100; $i+=0.1) {
for ($j=0; $j<=100; $j+=0.1) {
$area = $i*$j;
$cost = $i*1200 + ($i+$j*2) * 2500;
if($cost > $amount) {
break;
}
}
}pickle | Please use [ syntax=php ], [ syntax=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: