1
$\begingroup$

I've been trying to create my own random number library(in java). I've searched for randomization and Blum Blum Shub algorithm looks good. It needs a start value, it is not actually random. So i get unix timestamp mod(10) for first value. Now i can generate random numbers. My question is; how can i modify my structure with range? I mean, i want to generate that numbers in a range. (I don't want to use java's another classes or functions) Any advices? Thanks in advance.

EDİT:I coded $\ x(n+1)= x(n)^2mod(M) \\$ formula and gived x(0) unix timestamp's last digit and M=191. So i get random numbers with Blum Blum Shub. But i want to get that numbers in a range. It is not about my code. It is about the formula and method actually.

$\endgroup$
  • $\begingroup$ start value + (random number%(end value - start value)) This May work for your case $\endgroup$ – Deep Joshi Mar 21 '17 at 12:12
  • $\begingroup$ If start=0 end=25 and unix digit=3, result will be 3. If unix=5 result=0... It mostly will return small digits. I need something like Blum Blum Shub and i'm looking a way for make it with range. $\endgroup$ – Furkan Ayık Mar 21 '17 at 12:29
  • $\begingroup$ stackoverflow.com/q/2509679/781723, c-faq.com/lib/randrange.html $\endgroup$ – D.W. Mar 21 '17 at 15:38
  • $\begingroup$ Raw links don't help nearly so much as a simple explanation of why to visit the link. $\endgroup$ – SDsolar Mar 23 '17 at 7:42
  • $\begingroup$ Hi everyone. I changed my structure and i didn't use blum blum shub. I just use timestamp MOD(range) for range. My question was not so clear i think and i'm sorry for that and i'll work on subject again. But thank you all for time and help. $\endgroup$ – Furkan Ayık Mar 23 '17 at 10:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.