Coding challenge

Write some code that chooses x=math.random() and finds the probability that the fractional part of $1/x$ (the part to the right of the decimal only) is greater than x? What is the average value of the fractional part of $1/x$? (Ref: https://www.reddit.com/r/mathriddles/comments/46cem2/fractional_part_of_reciprocal/).

Type your code here:


Lua reference

See your results here: