# Subtract with carry

Subtract with carry is a pseudorandom number generator of the lagged Fibonacci type introduced by George Marsaglia and Arif Zaman in 1991.[1] It is one of three random number generator engines included in the standard C++11 library.

Subtract with carry generates a sequence of numbers using the recurrence relation:

$x(i) = (x(i-S)-x(i-R)-cy(i-1))\ \bmod\ M$

where $cy(i)$ has the value 1 if $x(i-S)-x(i-R)-cy(i-1)<0$, otherwise $cy(i) = 0$. R and S are constants known as the long and short lags.[2]

## References

1. ^ A New Class of Random Number Generators, George Marsaglia and Arif Zaman, The Annals of Applied Probability, Vol. 1, No. 3, 1991
2. ^ subtract_with_carry Class, Microsoft Visual Studio 2010