To get the right answer from a formula we must use the same units.
Here the Earth’s radius is about 3960 miles.
If we are given height h in feet, then the height in miles is h/5280.
The resulting distance to the horizon will then be in miles.
Unfortunately, I get a different formula to you. Here is how I worked it out.
Draw a circle representing the Earth. Draw a line from the centre to a point a little above the surface, of length R + h. Draw a tangent from here to the circle, to represent the observer's sight line to the horizon, and mark it d. Draw in the radius R meeting the tangential point.
By Pythagoras, d^2 = (R+h)^2 - R^2 ~ 2Rh = (2 x 3960 x h in feet)/5280 = 1.5(h in feet)
That would make my version of the formula:
d in miles ~ SQRT of [1.5(h in feet)]
If h = 40,000 feet, d in miles ~ SQRT of [1.5 x 40,000] ~ 245 miles
I hope this was helpful
Regards - Ian