Mass m is attached to the upper end of a mass less spring with a constant of k.
The lower end of spring is attached to a firm surface of a rigid body.
under the weight, the spring gets compressed a little, the displacement being α. The mass stays in equilibrium and stationary. Let us call the displacement from this equilibrium position = x, positive upwards.
m g = k α => α = m g / k
Now if the mass is displaced a little from this equilibrium, then it will oscillated in SHM. Let X be the displacement of the mass from its unextended length. Let x be the displacement from the equilibrium position.
X = x - α
Forces acting on the mass: - m g downwards. and - k x (negative as when x is positive, the force is downwards).
F = m a = m d²X / dt² = - m g - k X
m d²x/ dt² = - m g - k x + k α = - k x = - ω² x
so angular frequency = ω = √(k/m)
frequency = f = ω/2π = 1/2π √(k/m)