Friday, December 19, 2008

Neat math trick

Lets say you need some random numbers, or at least ones that exhibit statistical randomness, and you don't have a calculator or computer will you. You know that 7=2*3+1. One divided by seven will give a series of semi-random numbers, six of them. This can be done for many different numbers. Here are the requirements:

Let a be a prime number.

Let b be a prime number such that b=2a+1

1/b will produce a string of semi-random numbers. The string will have length b-1.

I found this in the Wikipedia page for the multiplicative inverse. Happy pseudo-random trails!

No comments: