minstd 0.9.4

MINSTD minimal standard random number generator
Documentation
/*
MINSTD Multiplicative congruential generator
implementation by Radim Kolar <hsn@sendmail.cz> 2024
https://gitlab.com/hsn10/minstd

This is free and unencumbered software released into the public domain.
SPDX-License-Identifier: Unlicense OR CC0-1.0

For more information, please refer to <http://unlicense.org/>
*/

use super::MINSTD;

/** Consecutive values produced by the C++ minstd_rand
    random number generator with the default seed (1). */
const A221556 : [ i32; 24] = [1,48271,182605794,1291394886,1914720637,2078669041,
                              407355683,1105902161,854716505,564586691,
                              1596680831,192302371,1203428207,1250328747,
                              1738531149,1271135913,1098894339,1882556969,
                              2136927794,1559527823,2075782095,638022372,
                              914937185,1931656580];

#[test]
fn A221556_seq_test() {
   let mut g = MINSTD::seed(A221556[0]);
   for i in 1..A221556.len() {
      assert_eq!( g.next(), A221556[i]);
   }
}

/* test vector https://oeis.org/A221556/b221556.txt */
#[test]
fn check_10kth_value() {
   let mut g = MINSTD::seed(A221556[0]);
   for _ in 1..10000 {
      g.next();
   }
   assert_eq! ( g.next(), 399268537 );
}