by cjackson · 12y ago · 0 comments
n n % 4
-----------
0 0
1 1
2 2
3 3
4 0
5 1
6 2
7 3
8 0
9 1
10 2
11 3
12 0
13 1
14 2
15 3
EDIT: It must be really, really satisfying to be able to anonymously downvote posts that actually reveal such things as grade-school arithmetic -- thus contributing to the intellectual wasteland that most accurately represents America in the early 21st century.The pattern is clear and ubiquitous -- if you actually know something, and if you're foolish enough to post a clear exposition, the morons who never post anything coherent will downvote your posts with a probability approaching certainty.
The modulo operator is the obvious solution to the original question. And if there were't an atmosphere of pervasive anti-intellectualism at HN, this thread would be much shorted than it is.
0 % 7 = 0
1 % 7 = 1
2 % 7 = 2
.
.
.
56 % 7 = 0
57 % 7 = 1
58 % 7 = 2
59 % 7 = 3
From this, you can clearly see that: 0 appears nine times.
1 appears nine times.
2 appears nine times.
3 appears nine times.
4 appears *eight* times.
5 appears *eight* times.
6 appears *eight* times.
This is not fair, and is an actual problem in real life: Two examples off the top of my head is when drawing cards in electronic poker games (where slight biases in the PRNG can be exploited by those who notice them) and in cryptography.