Average distance of two points in unit n-dimensional hypercube An easy way to understand the unit n-dimensional hypercube is to consider the region of space in n dimensions that you can get if every coordinate component lies in [0, 1]. So for one dimension it's the line segment from 0 to 1, for two dimensions it's the square with corners (0, 0) and (1, 1), etc.

Write a program or function that given n returns the average Euclidean distance of two points uniformly random selected from the unit n-dimension hypercube. Your answer must be within 10-6 of the actual value. It's ok if your answer overflows your language's native floating point type for big n.

Randomly selecting a 'big' number of points and calculating the average does not guarantee such accuracy.

Examples:


  1 &rightarrow; 0.3333333333...
  2 &rightarrow; 0.5214054331...
  3 &rightarrow; 0.6617071822...
  4 &rightarrow; 0.7776656535...
  5 &rightarrow; 0.8785309152...
  6 &rightarrow; 0.9689420830...
  7 &rightarrow; 1.0515838734...
  8 &rightarrow; 1.1281653402...


Data acquired from MathWorld.

This is code-golf, lowest byte-count wins.
Mathematica, 68 bytes

NIntegrate[(1-((E^-u^2+u*Erf@u√π-1)/u^2)^#)/u^2,{u,0,∞}]/√π&amp;


Implementation of the formula using NIntegrate to approximate its value.