$matchsticks = intval(trim(fgets(STDIN))); $max_number = ""; if ($matchsticks == 1) exit("1"); if ($matchsticks == 3) exit("7"); while($matchsticks > 0) { $matchsticks -= 2; $max_number .= 1; } echo intval($max_number);