[algogeeks] Re: Generate random number from 1 to 10.

2014-02-06 Thread Don
Just noticed that you asked for 1-10, and my code will clearly generate 0-9. Add one for the desired range. Don On Wednesday, February 5, 2014 4:29:26 PM UTC-5, Don wrote: // Using George Marsaglia's Multiply With Carry generator int rnd10() { static unsigned int x = time(0); x =

[algogeeks] Re: Generate random number from 1 to 10.

2014-02-06 Thread SVIX
Just curious... Why is this more random than (getSystemTimeInMilliseconds() % 10) On Thursday, February 6, 2014 1:47:15 PM UTC-8, Don wrote: Just noticed that you asked for 1-10, and my code will clearly generate 0-9. Add one for the desired range. Don On Wednesday, February 5, 2014

Re: [algogeeks] Re: Generate random number from 1 to 10.

2014-02-06 Thread atul anand
@don: algo look fine..i tested it ,but it did not generate 1-10 with probabilty of 1/10 everytime. actually question was asked in an intrview. question started with displaying all elements in an array randomly without repetition i.e only once( probabilty 1/10)...which can be done with fisher yates