Find the rearrangements of 1234 in which at least one of the digits is in its original position I'm not sure if I'm doing it right.
So stick one in its original place, we can have:
$(3^3-3*2^3+3*1^3) * 3 = 18$ arrangements
 A: The easiest way to calculate $!n$ is through the recursion $!n=(n-1)(!(n-1)+!(n-2))$.
This gives $!1=0,!2=1,!3=2,!4=9$.
What you want is $4!-!4=24-9=15$.
A: Just find the amount of derangements we have. Or you can just brute-force casework:
If exactly one is in the correct position ($4$ ways to assign) there are $2$ ways to assign the last three so that they're all in the wrong places so that $8.$
If two are in the right position there are $\binom{4}{2}=6$ ways to pick those then there's only one way to "derange" the remaining two. That's $6.$
And there's no ways to have exactly three right, and of course the case where everything is in the right place ($1234$). So the answer is $8+6+1=\boxed{15}.$

Alternatively we can count the derangements as mentioned before:
For any permutation let $f(n)$ be the position of the said number. So for $4231$ $f(4)=1, f(2)=2,$ etc.
If we form a "4-cycle" (as in $f(a)=b, f(b)=c, f(c)=d,$ and $f(d)=a$) there are 3 ways to do it.
If there's two "2-cycles" (as in $f(a)=b$ and $f(b)=a$) there are $\binom{4}{2}=6$ ways to pick the first group of $2$ and $1$ way to pick the second group. And there's only one way to have everything messed up in this case. So the answer is  $24-(3+6)=\boxed{15}$, which was our answer with the first method.
Edit: If you want a general solution the other answer pretty much has it.
