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::MINSTD0;

/* This generator is also called "The minimal standard generator" or
   MCG16807. Generators of this form are ascribed to D. H. Lehmer, 
   first described by Hutchinson and independently by Downham and Roberts.
   It was first analyzed by Lewis, Goodman and Miller. */
const A096550: [i32; 21] =
[1,16807,282475249,1622650073,984943658,
 1144108930,470211272,101027544,1457850878,
 1458777923,2007237709,823564440,1115438165,
 1784484492,74243042,114807987,1137522503,
 1441282327,16531729,823378840,143542612];

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

/* test vector https://oeis.org/A096550/b096550.txt */
#[test]
fn check_10kth_value() {
   let mut g = MINSTD0::seed(A096550[0]);
   for _ in 2..10000 {
      g.next();
   }
   assert_eq! ( g.next(), 1484786315 );
}