Answer the question
In order to leave comments, you need to log in
How to find the original number?
X + 30% of Y = Y
or
X = Y - 30% of Y
Find Y where X = integer.
function search_statr_value($price, $sale, $max_price = false) {
if( $max_price === false ) {
$max_price = $price * 100;
}
$resultPrice = round(($max_price/100)*$sale);
// Нашли !
if($price == $resultPrice) {
return $max_price;
}
if($resultPrice > $price) {
return search_statr_value($price, $sale, $max_price/2, $max_price);
}
if($resultPrice < $price) {
return search_statr_value($price, $sale, round($max_price+($max_price/2)));
}
}
echo search_statr_value(1499, 30);
Answer the question
In order to leave comments, you need to log in
only neural networks need to be solved! X = 0.7 * Y
What is difficult here? Find all pairs (X, Y) where both are integers ?
Whether the skis do not go ..
function search_start_value($price, $sale) {
return $price * 100 / (100 - $sale);
}
echo search_statr_value(1499, 30); // 2141,4285714286
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question