Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

You should be able to solve this

Name: The Silent Wind of Doom 2009-01-09 15:55

A common algorithm for generating pseudorandom numbers is a "linear congruential generator" which uses the following procedure:

1) A positive integer m and two integers a and b between 0 and m−1 are fixed.

2) A seed r(0) between 0 and m−1 is input.

3) After that, numbers are generated by the recurrence r(n+1) = ar(n)+b (mod m).  (So that 0 <= r(n+1) <= m−1).


The following sequence of numbers was generated in this way.

6543
6331
9584
9025
3911

Find a,b, and m.

(crossposted from /sci/, cuz i herd u liek math).

Name: Anonymous 2009-01-09 22:27

solve = [ (a,b,m) | m <- [1 .. 15000],
                    a <- [0 .. m],
                    b <- [0 .. m],
                    9025 == (9584 * a + b) `mod` m,
                    3911 == (9025 * a + b) `mod` m,
                    6331 == (6543 * a + b) `mod` m ]


Sounds like it should work but Haskell has this nasty habit of driving my C2D over 90C when I make it crunch numbers.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List