Is this use of L'Hôpital's rule incorrect? For the question:

Find the $\lim_{x \to 1}  \frac{3x^3 - 5x^2 + x + 1}{x^2 - 2x + 1}$

I couldn't see how to factorize the numerator and noticed that it was in intermediate form $\frac{0}{0}$ so I applied L'Hôpital's rule twice which left me with:
$\frac{18x - 10}{2}$
which I evaluated at $x \rightarrow 1$ to get the limit of 4.
I then typed the problem into wolfram alpha and noticed that, although I got the same answer, WA had factored out $x^2 - 2x +1$ which cancels with the denominator and then the function can be evaluated to equal 4 without using L'Hôpital's.
I was wondering if my use of L'Hôpital's rule here is unjustified, and if so, what would have been the method to factor the numerator?
 A: As I teach to my students (I'm italian, so there might be an issue about pedagogical viewpoints and tradition), you can apply De l'Hospital's theorem whenever its assumptions are satisfied. In you problem they surely are. Anyway, many colleagues think that limits should be solved without derivatives whenever possible. I guess the answer to your question depends on the rules given by your teacher. Mathematically speaking, your application of De l'Hospital's rule is correct.
A: $$\lim_{x \to 1}  \frac{3x^3 - 5x^2 + x + 1}{x^2 - 2x + 1}$$
If you saw that you get $0/0$, that should tell you how to factor both the numerator and the denominator.  I.e., if you plug in a number---call it $c$---and get $0$, that tells you that $(x-c)$ is one of the factors.  In this case you plugged in $1$ and got $0$, so $(x-1)$ is one of the factors.  So you get
$$
\lim_{x \to 1}  \frac{(\cdots\cdots)(x-1)}{(\cdots\cdots)(x-1)}.
$$
You can then use long division to fill in the remaining blanks, if all else fails.  But once you get this far, you can often fill in the blanks by staring at the thing.  You get
$$
\lim_{x \to 1}  \frac{(3x^2-2x-1)(x-1)}{(x-1)(x-1)}
$$
and this becomes
$$
\lim_{x \to 1}  \frac{3x^2-2x-1}{x-1}.
$$
You've still got $0/0$, so do it again:
$$
\lim_{x \to 1}  \frac{3x^2-2x-1}{x-1}=\lim_{x\to 1} \frac{(\cdots\cdots)(x-1)}{(\cdots\cdots)(x-1)}.
$$
One problem with L'Hopital's rule: It will get you the limit, but it's valid only if your method of finding derivatives is valid.  Sometimes you use limits involving $0/0$ to prove that methods of finding derivatives are valid.  If you use those methods to find the limits, and then use the limits to prove those methods are valid, then you've got the two methods vouching for each other, so there's a gap in the logic.
A: L'Hopital's rule
To factorize the numerator :
$3x^3-5x^2+x+1=3x^3-6x^2+x^2+3x-2x+1=(3x^3-6x^2+3x)+(x^2-2x+1)=$
$=3x(x-1)^2+(x-1)^2=(3x+1)(x-1)^2$
Hence :
$\displaystyle\lim_{x \to 1} \frac{(3x+1)(x-1)^2}{(x-1)^2}=4$
