How does friction affect simple harmonic motion? Today I had my Physics final exam. In it, we were asked to find the time at which a block attached to a spring on a horizontal surface came to a halt knowing that there is friction. Also, we had the initial conditions (equilibrium position at t = 0 and its corresponding initial velocity). 
I have never solved a problem like this with friction. I just ignored it since when doing the analysis of forces that act on the object, it is just a term that does not depend on x. Is this okay or should we take friction into account?
I am posting this here to gain some insight in this topic, this is not a homework question since I already finished this course. I just want to understand SHM.
All help appreciated.
Edit: the exact statement (as I remember) is:

A block is against a spring at rest at x = 0. Knowing that it is given
  a slight push so that its initial speed is 2 m/s, calculate the
  position at which the block comes to rest for the second time.
Data: mass = 1 kg; $\mu_k = 0.3$; k = 900 N/m

 A: EDIT:
It turns out that this answer is rather irrelevant as it does not address the question at hand which was edited to show that it speaks of kinetic friction as opposed to viscous damping as assumed here. 

Let's try and understand what's happening physically, so that when we get our mathematical answer, we can check to see if it makes sense. Something I like to do first is consider limiting cases. Let's assume your block's on a table that is completely frictionless. In this ideal case, it would continue to oscillate with a constant amplitude. 
Now consider a small frictional force. Since I don't know what model of friction they asked you to solve for, the standard model for such problems introduces a "damping" term that is proportional to the velocity of the particle at that time, so while it does not depend explicitly on the position, it is certainly not a constant! Well, with a small frictional force, the object would continue to oscillate, but it wouldn't be unreasonable to assume that the amplitude would start to decrease ever so slightly with each oscillation.
Now what if I introduced a large damping force? Imagine stretching out your block-on-a-spring and letting it go. The damping would be so strong that the object would not oscillate at all, but just come to rest. Thus our solution must clearly have two regimes, separated by some characteristic value of one of the parameters (say, $\gamma$, the damping coefficient).
Let's actually try and compute something with this. When you describe the forces acting on the particle,  you must now include a frictional force, given by $F_v = \gamma mv = -\gamma m\dot{x}$, where the dots refer to differentiation with respect to time. Note that $\gamma$ must be positive, since the frictional force is always in the opposite direction of the velocity, as it works to slow down the particle! How does Newton's equation $F=ma$ look now?
$$F = m \ddot{x}=-k x - \gamma m \dot{x}$$
Writing this out explicitly, you see that 
$$\ddot{x} + \gamma \dot{x} + \omega^2 x = 0$$
Such a differential equation is slightly harder to solve that the simple case, but the same rather standard technique can be used: consider a solution of the form $x(t) = A e^{\alpha t}$. The exponential has the nice property that is converts such differential equations into algebraic equations. Plugging it into the equation, you'd get that 
$$\alpha^2 + \gamma \alpha + \omega^2 = 0$$
which would lead you to two distinct values of $\alpha$ (as we would expect, since it's a second order differential equation with two solutions in general), $\alpha_+$ and $\alpha_-$.
$$\alpha_{\pm} = \frac{-\gamma}{2} \pm \sqrt{\frac{\gamma^2}{4} - \omega^2}$$
We now see something interesting: remember (for real $a$) that when you have a function $e^{-a t}$, it is an exponentially decaying solution, while a function $e^{iat}$ is an oscillatory solution (it can be expressed as a linear sum of sines and cosines).
Let's observe one of our solutions, say 
$$e^{\alpha_1 t} = e^{-\frac{\gamma}{2}t}\,e^{t\sqrt{\frac{\gamma^2}{4} - \omega^2}}$$
We can now see that for all values of $\gamma^2\geq 4\omega^2$, the solution is purely an exponential decay. However, when $\gamma^2< 4\omega^2$, a critical value we intuitively imagined would exist, the solution is a combination of an exponentially decaying part and an oscillating part, since the root is imaginary!
I agree with @James' comment that finding the solution for it to come to rest might be relatively difficult if you haven't been exposed to this before, but nevertheless we can still get some information out of this solution. As can be seen, when $\gamma^2< 4\omega^2$, the final solution of a damped harmonic oscillation is just something of the form:
$$x(t) = e^{-\frac{\gamma}{2}t} \left(A \sin \omega_1 t + B\cos \omega_1 t \right)$$
where $\omega_1$ is just some constant modified frequency, different from the natural frequency of the system. We can clearly see that there is a time scale associated to this problem (this is an argument that is made very often in physics), related to the inverse of $\gamma$. The exponential function is very rapidly decreasing, at $e^{-2}\approx 0.1$, the amplitude has already decreased by a factor of 10. I might be able to answer more if you actually gave us the exact question, but I hope this helped!
A: I would use energy conservation. 
The block has initial kinetic energy $K_0=\frac 12 mv_0^2$.


*

*Until the first stop this is turned into elastic potential energy $U_1=\frac 12 kx_1^2$ and energy loss by friction: $W_{0-1}=f_k(x_1-x_0)=\mu_k n x_1$.

*The energy stored at the first stop is until the second stop again turned into elastic potential energy $U_2=\frac 12 kx_2^2$ and friction loss: $W_{1-2}=\mu_k n (x_2-x_1)$.
Set up the two equations, and it looks like you only have the two positions as unknowns. This should be simple algebra to solve if I didn't miss something. 
A: EDIT: As the original question has been clarified. This answer is also no longer relevant!
I'm not sure what level your maths is at, this came up in my first year college applied maths exam.
The equation for an undamped spring oscillating is
$ mu'' + ku = 0 $
the general solutions is 
$ u(t) = C_1 \cos \omega t + C_2 \sin \omega t$
where $ \omega = \sqrt{k/m}$ - is the natural frequency of the system
When there is friction, you now have a damped system.
$ mu″ + γu′ + ku = 0 $   is the equation you now have to solve
where γ is your damping constant (in this case your friction)
If they are real roots you get an answer of
$ u(t) = C_1e^{r_1t} + C_2e^{r_2t} $
I don't think he would have given you anything more difficult than that to solve. But if you want to explore it further here's a good link I found. https://sites.psu.edu/s17m250s4n5/files/2017/02/10.Mechanical-Vibrations-1fhhmvs.pdf
