Guessing a positive integer : the universal distribution.

First enumerate all binary sequences :

suite[entier_]:=Rest[IntegerDigits[entier,2]]

Table[{n,suite[n]},{n,1,16}]

Prefixing binary sequences, hence positive integers :

redux[suite_]:=Rest[IntegerDigits[Length[suite],2]]

pref[suite_]:=Piecewise[{{{1,0},suite=={}},{{1,1,0},suite=={0}},{{1,1,1},suite=={1}}},Flatten[Join[Table[0,{Length[Reverse[NestWhileList[redux,suite,Length[#]>3&]]]}],IntegerDigits[Length[First[Reverse[NestWhileList[redux,suite,Length[#]>3&]]]],2],Reverse[NestWhileList[redux,suite,Length[#]>3&]]]]]

Table[{n,pref[suite[n]]},{n,1,16}]                (*Universal prefix binary code for positive integers*)

Table[{2^n,pref[suite[2^n]]},{n,2,8}]                (*Universal prefix binary code for powers of two (>2)*)

Table[{2^2^n-1,pref[suite[2^2^n-1]]},{n,1,4}]                    (*Universal prefix binary code for powers of power of two (>2)*)

Universal probability distribution, g(n), for positive integers :

g[n_]:=2^-Length[pref[suite[n]]]

Table[g[n],{n,1,32}]

PieChart[ Append[ Table[g[k],{k,1,31}],1-Total[Table[g[k],{k,1,31}]]],ChartStyle->"DarkRainbow",ChartLabels->Placed[{Style["1",Bold],Style["2",Bold],Style["3",Bold],Style["4",Bold],Style["5",Bold],Style["6",Bold],Style["7",Bold]},"RadialCallout"],Ticks->None]

Normalisation of the universal distribution :

g[1]+g[2]+g[3]                (*First contribution*)

Total[Table[g[n],{n,(2^2),(2^(2^2))-1}]]              (*Second contribution*)

Total[Table[g[n],{n,(2^(2^2)),(2^(2^(2^2)))-1}]]                   (*Third contribution*)

Sum[(1/(2^k)),{k,1,∞}]

List of the code lengths and their asymptotic behaviour :

ℓ[k_]:=Length[pref[suite[2^k]]]

Table[ℓ[k],{k,0,100}]

g1=ListLinePlot[Table[ℓ[k],{k,0,100}],PlotStyle->{Orange,Thick}]

f[x_]:=Log[2,x]

as[k_]:=N[k+Sum[Nest[f,k,j],{j,Length[NestWhileList[f[#]&,k,#>1&,1,∞]]}],12]

{((ℓ[100])/(as[101])),((ℓ[1000])/(as[1001])),((ℓ[10000])/(as[10001]))}

g2=Plot[as[k+1],{k,0,100},PlotStyle->{Blue,Thick}]

Show[g1,g2,Frame->True,FrameStyle->Directive[20]]

g[n]==1/2^ℓ[Floor[Log[2,n]]]

PieChart[Table[1,{n,32}],ChartStyle->"DarkRainbow",ChartLabels->Placed[{Style["1",Bold],Style["2",Bold],Style["3",Bold],Style["4",Bold],Style["5",Bold],Style["6",Bold],Style["7",Bold],Style["8",Bold]},"RadialCallout"],Ticks->None]

PieChart[Append[Table[(1/(n^2)),{n,15}],((π^2)/6)-Total[Table[(1/(n^2)),{n,15}]]],ChartStyle->"DarkRainbow",ChartLabels->Placed[{Style["1",Bold],Style["2",Bold],Style["3",Bold],Style["4",Bold],Style["5",Bold],Style["6",Bold],Style["7",Bold]},"RadialCallout"],Ticks->None]