root of root of root of root

Python 2, 104 94 89 81 79 bytes

s=n=input()
while s:print' '*s,'/ '*(n-s)+'_'*(2*s+len(`n`));s-=1
print'\/'*n,n

Try it online!

Edit 1: Forgot I switched to python 2 lol

Edit 2: Thanks @ElPedro for the idea of switching to while loop!

Edit 3: Thanks @SurculoseSputum for saving 8 bytes!

Edit 4: Thanks @xnor for saving 2 bytes!


JavaScript (ES6),  104 102  99 bytes

A recursive function starting with the last line and using regular expressions to update each line above.

f=(n,s='\\/'.repeat(n)+(e=' ')+n)=>~n?f(n-1,e+s.replace(/\\/g,e).replace(/.(?!.*\/)/g,'_'))+`
`+s:e

Try it online!

How?

Initialization

We generate the bottom line with:

s = '\\/'.repeat(n) + (e = ' ') + n

For instance, this gives "\/\/\/\/ 4" for \$n=4\$.

Recursion

We get rid of the backslashes with:

s.replace(/\\/g, e)

We create the 'roof' or increase its size with:

.replace(/.(?!.*\/)/g, '_')

which means: replace with an underscore each character that doesn't have any slash on its right.

This leads to:

 _________
 / _______
 / / _____
 / / / ___
\/\/\/\/ 4

And with a leading space inserted at each iteration:

     _________ 
    / _______ 
   / / _____ 
  / / / ___ 
\/\/\/\/ 4 

Erlang (escript), 188 bytes

f(0,N)->string:copies("\\/",N)++" "++integer_to_list(N);f(X,N)->string:copies(" ",X+1)++string:copies("/ ",N-X)++string:copies("_",2*X+floor(math:log10(N)+1))++"
"++f(X-1,N).
f(N)->f(N,N).

Try it online!

Explanation

f(N)->f(N,N).   % Assign the counter to the input.
f(X,N)->        % While the counter isn't 0:
string:copies(" ",X+1)
                %     Repeat the space counter + 1 times

++string:copies("/ ",N-X)
                %     Repeat "/ " input - counter times

++string:copies("_",
                %     Repeat the "_" that many times:

2*X             %     The counter doubled
+floor(math:log10(N)+1)
                %     Plus the length of the digit(s) of the input
++"
"               %     Join the above, and append a newline
++f(X-1,N).     %     Decrement the counter by 1

f(0,N)->        % If the counter turns into 0:
string:copies("\\/",N)
                %     Repeat "\/" input times

++" "           %     Append a space
++integer_to_list(N);
                %     Append the number converted into a string
```