1) { //var_dump($a); $div = getLeastDivisor($a); $temp = array(); foreach ($div as $d) { $x = $a/$d; $c = $d * cpp($x)+1; array_push($temp , $c); } $s = max($temp); return $s; } return 1; // Return the length of the longest possible sequence of moves. } function getLeastDivisor($a) { $div = array(); for($i=2;$i<=$a;$i++) { if ($a%$i == 0) { array_push($div , $i); } } return $div; } fscanf($handle, "%i",$n); $a_temp = fgets($handle); $a = explode(" ",$a_temp); $a = array_map('intval', $a); $result = longestSequence($a); echo $result . "\n"; ?>