Discussion Ask HN: How many times will this loop run on average? A friend of mine shared the following code snippet with me and asked me to guess how many times the loop will run on average: for(int i = 0; i < Random(1, 100); i++); I tried to guess the answer analytically and gussed ~50 but the empirical test was surprising to me. Can someone explain why the average is around 12?Runnable code: https://replit.com/@aalhour/RandomLoop#main.pyEDIT: Formatting. 1 points aalhour 2 years ago 11 comments
Runnable code: https://replit.com/@aalhour/RandomLoop#main.py
EDIT: Formatting.