Jane Street interview question

Some probability and number theory puzzles