using System; namespace Test { class Program { public class SimpleMarsagliaRandom { private const uint original_w = 1023; private uint m_w = original_w; /* must not be zero */ private uint m_z = 0; /* must not be zero, initialized by the constructor */ public SimpleMarsagliaRandom() { this.init(666); } public void init(uint z) { this.m_w = original_w; this.m_z = z; } public uint get_random() { this.m_z = 36969 * (this.m_z & 65535) + (this.m_z >> 16); this.m_w = 18000 * (this.m_w & 65535) + (this.m_w >> 16); return (this.m_z << 16) + this.m_w; /* 32-bit result */ } public uint get_random(uint min, uint max) { // max excluded uint num = max - min; return (this.get_random() % num) + min; } } public static void Main() { var smr = new SimpleMarsagliaRandom(); for (int i = 0; i < 1000; i++) { Console.WriteLine(smr.get_random()); } } } }