Difference between revisions of "Template:PRNG"
Jump to navigation
Jump to search
Kevin Wang (talk | contribs) m |
Kevin Wang (talk | contribs) |
||
| Line 1: | Line 1: | ||
| − | <includeonly>{{#expr:( | + | <includeonly>{{#expr:((16843009*{{{1|1}}} + 826366247) mod {{{2|4294967296}}}) + 1}}</includeonly><noinclude>{{Template doc| |
| − | A simple [https://en.wikipedia.org/wiki/Linear_congruential_generator linear congruential generator] for generating bad random numbers using the parameters "<nowiki>X_{n+1}= | + | A simple [https://en.wikipedia.org/wiki/Linear_congruential_generator linear congruential generator] for generating bad random numbers using the parameters "<nowiki>X_{n+1}=(16843009 X_n + 826366247) mod 4,294,967,296 + 1</nowiki>" (the values from cc65's rand). |
* arg1 - input | * arg1 - input | ||
* arg2 - mod (optional) | * arg2 - mod (optional) | ||
| − | <pre> | + | {{Table start}} |
| + | ! Case | ||
| + | ! Result | ||
| + | {{!-}} | ||
| + | {{!}} <pre> | ||
{{PRNG|1}}, {{PRNG|2}}, {{PRNG|3}}, {{PRNG|4}}, {{PRNG|5}} | {{PRNG|1}}, {{PRNG|2}}, {{PRNG|3}}, {{PRNG|4}}, {{PRNG|5}} | ||
| + | </pre> | ||
| + | {{!}} {{PRNG|1}}, {{PRNG|2}}, {{PRNG|3}}, {{PRNG|4}}, {{PRNG|5}} | ||
| + | {{!-}} | ||
| + | {{!}} <pre> | ||
| + | {{PRNG|1|2}}, {{PRNG|2|2}}, {{PRNG|3|2}}, {{PRNG|4|2}}, {{PRNG|5|2}} | ||
| + | </pre> | ||
| + | {{!}} {{PRNG|1|2}}, {{PRNG|2|2}}, {{PRNG|3|2}}, {{PRNG|4|2}}, {{PRNG|5|2}} | ||
| + | {{!-}} | ||
| + | {{!}} <pre> | ||
| + | {{PRNG|{{PRNG|1}}}}, {{PRNG|{{PRNG|2}}}}, {{PRNG|{{PRNG|3}}}} | ||
| + | {{PRNG|{{PRNG|1}}|5}}, {{PRNG|{{PRNG|2}}|5}}, {{PRNG|{{PRNG|3}}|5}} | ||
| + | </pre> | ||
| + | {{!}} {{PRNG|{{PRNG|1}}}}, {{PRNG|{{PRNG|2}}}}, {{PRNG|{{PRNG|3}}}} | ||
| − | {{PRNG|1| | + | {{PRNG|{{PRNG|1}}|5}}, {{PRNG|{{PRNG|2}}|5}}, {{PRNG|{{PRNG|3}}|5}} |
| + | {{!-}} | ||
| + | {{!}} <pre> | ||
| + | {{PRNG|{{PRNG|{{PRNG|1}}}}}}, {{PRNG|{{PRNG|{{PRNG|2}}}}}}, {{PRNG|{{PRNG|{{PRNG|3}}}}}} | ||
| + | {{PRNG|{{PRNG|{{PRNG|1}}}}|5}}, {{PRNG|{{PRNG|{{PRNG|2}}}}|5}}, {{PRNG|{{PRNG|{{PRNG|3}}}}|5}} | ||
</pre> | </pre> | ||
| − | {{PRNG|1}}, {{PRNG|2}}, {{PRNG|3}}, {{PRNG| | + | {{!}} {{PRNG|{{PRNG|{{PRNG|1}}}}}}, {{PRNG|{{PRNG|{{PRNG|2}}}}}}, {{PRNG|{{PRNG|{{PRNG|3}}}}}} |
| + | |||
| + | {{PRNG|{{PRNG|{{PRNG|1}}}}|5}}, {{PRNG|{{PRNG|{{PRNG|2}}}}|5}}, {{PRNG|{{PRNG|{{PRNG|3}}}}|5}} | ||
| + | {{Table end}} | ||
| − | |||
}}</noinclude> | }}</noinclude> | ||
Latest revision as of 16:04, 9 January 2026
Template documentation
A simple linear congruential generator for generating bad random numbers using the parameters "X_{n+1}=(16843009 X_n + 826366247) mod 4,294,967,296 + 1" (the values from cc65's rand).
- arg1 - input
- arg2 - mod (optional)
| Case | Result |
|---|---|
{{PRNG|1}}, {{PRNG|2}}, {{PRNG|3}}, {{PRNG|4}}, {{PRNG|5}}
|
843209257, 860052266, 876895275, 893738284, 910581293 |
{{PRNG|1|2}}, {{PRNG|2|2}}, {{PRNG|3|2}}, {{PRNG|4|2}}, {{PRNG|5|2}}
|
1, 2, 1, 2, 1 |
{{PRNG|{{PRNG|1}}}}, {{PRNG|{{PRNG|2}}}}, {{PRNG|{{PRNG|3}}}}
{{PRNG|{{PRNG|1}}|5}}, {{PRNG|{{PRNG|2}}|5}}, {{PRNG|{{PRNG|3}}|5}}
|
688315473, 755621457, 822927445
1, 1, 5 |
{{PRNG|{{PRNG|{{PRNG|1}}}}}}, {{PRNG|{{PRNG|{{PRNG|2}}}}}}, {{PRNG|{{PRNG|{{PRNG|3}}}}}}
{{PRNG|{{PRNG|{{PRNG|1}}}}|5}}, {{PRNG|{{PRNG|{{PRNG|2}}}}|5}}, {{PRNG|{{PRNG|{{PRNG|3}}}}|5}}
|
2390066809, 2541389945, 2760085117
5, 1, 3 |