I ran the following script, It starts with a random number, then takes it's reciprocal and gets it's fractional part, Then it repeats it again, and takes average.
var x = Math.random();
var i = 0;
var k = 0;
var n; //number of iterations
while (i<n) {
x = (1/x)%1;
k+=x;
i++;
}
console.log(k/n);
The outputs where as follows
when n=100, output=0.45473379363722793
when n=1000, output=0.4517287948011644
when n=10000, output=0.4411420299062774
when n=100000, output=0.4423720018398649
when n=1000000, output=0.4423947214693864
when n=10000000, output=0.442541609651593
Thus the output seems to converge around something like 0.442..
Is there a method to find the average for infinite iterations (theoretically)?
Is there any significance of that number?