Let x represent a positive integer. If x is added to its double and then to its square, the resulting sum equals 42. What is the value of x?
In mathematical terms, the equation is represented as:
$$x + 2x + x^2 = 42$$