A C implementation of several utilities for working with Linear Congruential Generators (LCGs), one of the simplest and historically important classes of pseudo-random number generators.
The project explores the mathematical properties of LCGs and provides tools for generating sequences and analyzing generator parameters.
A linear congruential generator produces a sequence according to the recurrence relation
Xₙ₊₁ = (aXₙ + c) mod m
where:
X₀— initial seeda— multiplierc— incrementm— modulus
The quality and period of the generated sequence strongly depend on the chosen parameters.
- Generation of pseudo-random sequences using an LCG
- Search for valid multiplier coefficients
- Search for valid increment coefficients
- Basic number-theoretic utilities used in parameter analysis
- Reading commands from an input file and writing results to an output file
This project was developed as an educational exercise focused on:
- pseudo-random number generation;
- linear congruential generators;
- elementary number theory;
- implementation of mathematical algorithms in C.
gcc main.c -o lcgThe program processes commands from an input file and writes results to an output file.
Example tasks include:
- generating an LCG sequence;
- finding suitable generator parameters;
- testing mathematical conditions related to generator periods.
This project is intended for educational purposes and does not aim to provide a production-quality random number generator.
- Donald E. Knuth, The Art of Computer Programming, Volume 2: Seminumerical Algorithms
- Hull, T. E., Dobell, A. R. "Random Number Generators"
- Numerical Recipes