Skip to main content
6 of 7
added 229 characters in body

Bash, 65 58 56 50 bytes

f()(echo ${a=$1};for((;a;)){ echo $[a=RANDOM%a];})

Try it online!

(Improved thanks to manatwork)

Recursive approach

Also 50

f()(echo $1;if((!$1));then exit;fi;f $[RANDOM%$1])

Try