static unsigned long
x=123456789,y=362436069,z=
/* replace defaults with five random seed values in calling program */
unsigned long xorshift(void)
{unsigned long t;
t=(x^(x>>7)); x=y; y=z; z=w; w=v;
v=(v^(v<<6))^(t^(t<<13)); return (y+y+1)*v;}
#include <stdint.h>
int main(void)
{
uint32_t lfsr = 1;
unsigned period = 0;
do
{
/* taps: 32 31 29 1; feedback polynomial: x^32 + x^31 + x^29 + x + 1 */
lfsr = (lfsr >> 1) ^ (-(lfsr & 1u) & 0xD0000001u);
++period;
} while(lfsr != 1u);
return 0;
}
seed=15239;
for (i=0;i<1000;i++){
seed =(86028157*seed + 142501)%1299689;
rand=seed/1299689;
print(rand);
}
Or the following if using type int.seed=43;
for (i=0;i<1000;i++){
seed =(5171*seed + 142501)%34421
rand=seed/34421;
print(rand);
}
Title | # Comments | Views | Activity |
---|---|---|---|
Dynamically create stored procedure using c# | 9 | 77 | |
Odds of picking games correctly | 4 | 31 | |
Chat Room | 1 | 29 | |
Problem to open Excel file | 15 | 44 |
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
19 Experts available now in Live!