Create a program that outputs itself.
However, if the source code is repeated n times (meaning to concatenate a copy of the source code to the end n-1 times), then there should be 1/n probability outputting the original source code, a 1/n probability of outputting the source code repeated twice, a 1/n probability of outputting the source code repeated three times, ..., and a 1/n probability of outputting the source code n times.
For example, if your program is
foobar, then it should always output exactly
However, if you run
foobarfoobarfoobarfoobar, then there should be a ¼ chance each of outputting
- The distribution of each possible output should be equal
- In addition to standard I/O methods applying and standard loopholes forbidden, standard quine rules apply (can't access its own source, etc.)
- This is code golf so shortest answer in bytes wins
foobarfoobar) then it'd only print
foobarrepeated two times, not once. \$\endgroup\$