+ 2

[TOUGHEST CHALLANGE OF ALL TIME] Random int output.

Come up with an algorithm that will generate a random integer. Every time you call this particular method or function it should return a random int. The method/function will take one argument of type int. This argument represents the range from zero to the integer argument, the int argument not included. For example outputRandomInt(10); should output any integer from 0 to 9. Thus if you wanted a range between 10 and 100 it would look something like this >> int a = outputRandomInt(91) + 10; Rules: You can use any language You cannot use any module or package It should pass my special randomness test. i.e calling the function/method n times the output should cover at least 50% of the distribution, n being the range (argument) . For example if a function/method looks like this outputRandomInt(10); , Calling the function 10 times the output should cover at least 50% of all integers between 0 and 9. Forgive my poor English please ask if not clear.

23rd Nov 2017, 5:28 AM
Nick Nderitu
Nick Nderitu - avatar
1 Answer