procedure main()
   local head, pre, post, nfact, tail, count, k

   head := "\\!\\(Solve[ n + x == 2\\ n + "
   pre := "1\\/\\("
   post := " +"
   nfact := "1\\/\\(n + x\\)"
   tail := ", x]\\)"

   writes(head)

   count := 0

   while k := read() do {
      writes(pre, k, post)
      count +:= 1
      }

   writes(nfact)
   writes(repl("\\)", count))	# closing parentheses
   write(tail)

end