Bash, <strike>65 58 56</strike> 50 bytes ================ f()(echo ${a=$1};for((;a;)){ echo $[a=RANDOM%a];}) [Try it online!][1] (Improved thanks to manatwork) **Recursive approach** <strike> 50 </strike> 28 f()(echo $1&&f $[RANDOM%$1]) [Try][2] [1]:https://tio.run/##S0oszvj/P01DUyM1OSNfQaU60VbFsNY6Lb9IQ8M60VpTs1oBIhGdaBvk6Ofi76uaGGtdq/k/TcHQwMDgPwA [2]:https://tio.run/##S0oszvj/P01DUyM1OSNfQcVQTS1NQSU6yNHPxd9XVcUwVvN/moKhgYHhfwA