Skip to content

Instantly share code, notes, and snippets.

@IISResetMe
Created March 11, 2020 16:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IISResetMe/93d1699c6ebf856add68cd200f697894 to your computer and use it in GitHub Desktop.
Save IISResetMe/93d1699c6ebf856add68cd200f697894 to your computer and use it in GitHub Desktop.
class LCG
{
hidden [long]
$factor = 1140671485
hidden [long]
$offset = 12820163
hidden [long]
$modulus = 16777216
[long]
$Seed
LCG()
{
$this.Seed = Get-Random
}
LCG([long]$seed)
{
$this.Seed = $seed
}
[long]
Next(){
return ($this.Seed = ($this.factor * $this.Seed + $this.offset) % $this.modulus)
}
}
@IISResetMe
Copy link
Author

IISResetMe commented Mar 11, 2020

$gen = [LCG]::new()
1..10 |% {$gen.Next()}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment