Processing math: 100%

Coding challenge

An integer x is chosen randomly between 10x99, via x=math.random(10,99). If all choices are equally likely, write some code to find the probability that at least one digit of x is a 7. Hint: use getdigit(x,n) to return the nth digit from the right of a number x. Ex: getdigit(1234,2) returns 3. (Ref: ACM 12B 2/25/2004.)

Type your code here:

 
1

Lua reference

See your results here: