1) { if($bar % 7 == 0) { $bar /= 7; $movesCounter += $iterationCounter; $iterationCounter *= 7; } elseif($bar % 5 == 0) { $bar /= 5; $movesCounter += $iterationCounter; $iterationCounter *= 5; } elseif($bar % 3 == 0) { $bar /= 3; $movesCounter += $iterationCounter; $iterationCounter *= 3; } elseif($bar % 2 == 0) { $bar /= 2; $movesCounter += $iterationCounter; $iterationCounter *= 2; } } $totalMoves += $movesCounter; } return $totalMoves; } fscanf($handle, "%i",$n); $a_temp = fgets($handle); $a = explode(" ",$a_temp); $a = array_map('intval', $a); $result = longestSequence($a); echo $result . "\n"; ?>