So I have this code:
<?php
for ($n = 0, $result = 0, $m = 1071225; (pow($n, 3) + $result + 1) !== $m || $n < 2; $n++) {
if ($n === 10) {
dd('stop');
}
$result += pow($n, 3);
}
dd($result);
?>
And when $n equals 3 my code doesn’t stop to execute – it stops when $n === 10, as I wrote this in my if condition. As far as I understand for loop, the middle part (in my case being):
(pow($n, 3) + $result + 1) !== $m || $n < 2
stands for stopping the code = so as I understand it will either stop if (pow($n, 3) + $result + 1) !== $m or $n < 2, but that doesn’t happen. Why is that?
I tried to solve this kata: https://www.codewars.com/kata/5592e3bd57b64d00f3000047/train/php and came up with an idea, so I tried it.