Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Zero collisions for all input 0 .. 65535
- // Does not seem to get stuck in a tight predictable sequence.
- // I can't predict nor see a pattern in its output.
- // Test cases: http://pastebin.com/Kz7dLGBC
- #include <stdint.h>
- uint16_t
- get_random_number(uint16_t seed)
- {
- uint16_t out = (seed + 1) * (0xacdc + 1);
- return out == seed ? ++out : out;
- }
- // Unlike Munroe's RNG (xkcd.com/221), it's not *guaranteed* to be random, as it wasn't chosen by a fair dice roll
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement