Click here to Skip to main content
15,922,894 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to use RSA or des,md5 TO make a random number generator?
Posted
Updated 2-Apr-11 6:52am
v2

To answer the follow-up Question:

So, this is a school assignment… In this case, don't count on much help.
However, you can solve your problem if you start from here: http://en.wikipedia.org/wiki/Random_number_generation#Computational_methods[^]. One of the algorithm is right on this page. Also, try to find the algorithms following the references from this document.

—SA
 
Share this answer
 
I wouldn't use any of them to make a random number generator: none of them generate data which is random. It may look it, but statistical analysis will almost certainly show patterns - which is not what you want in a random number generator.

Why not just use the Random class[^]?
private Random rand = new Random();
...
for(int i = 0; i < 10; i++)
   {
   Console.WriteLine(rand.Next(100).ToString());
   }
Will give you 10 random numbers between 0 and 99 inclusive.

[edit]"not" inserted in the phrase "which is not what you want in a random number generator" How could I miss that? Easy... - OriginalGriff[/edit]
 
Share this answer
 
v2
Comments
Sandeep Mewara 3-Apr-11 5:33am    
Comment from OP:
Thank you!
I know your method.It is easy to know.But our teacher tell us to use different ways to make a random number generator,such as
random,RSA.
Sergey Alexandrovich Kryukov 5-Apr-11 0:04am    
@EIYANGXINQU: You should have mentioned it from the very beginning. Do you think people have too much time, so they can afford answering sloppy questions? Please, be accurate.
--SA
Sergey Alexandrovich Kryukov 4-Apr-11 23:56pm    
This is a strange understanding if "different". Do you want other bad ideas: use fibonacci, decimal digits of PI, Feigenbaum constants, Chibyshev polynoms... They are not worse albeit not better the yours in generating random numbers.
--SA
Sergey Alexandrovich Kryukov 4-Apr-11 23:57pm    
Good answer, my 5.
--SA
Sergey Alexandrovich Kryukov 5-Apr-11 0:02am    
Actually, I added my Answer taking into account OP's comment; how to do it not using existing Random.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900