I think they're looking deeper, like how would you generate "randomness" to produce a number between 1 and 7, like a linear congruential generator.
1
Anonymous
3 May 2016
Three!
1
Anonymous
10 Sept 2016
Five!
Anonymous
8 Sept 2012
This problem is ill-defined. What kind of number? I would tell them I select pi if they don't tell you what kind of objects you are working with.
1
Anonymous
3 Dec 2012
For floats:
(new Random()).nextFloat() * 6 + 1;
For ints:
(new Random().nextInt(6) + 1;
Use the 1-argument Random constructor with a random seed for non-deterministic results.