Language Core Java 1.5 (do not use Random function of java)
Write a methodA that returns a random number between 0 to 3, Use the same methodA to return a random number between 0 and 7. (do not use Random function) .This is a question which comes under uniform distribution principle.
Assume i write a methodA and i have to dynamically pass either 0 or 1 or 2 or 3 to the same methodA,this methodA should display a number between 0 to 7
Rand3(int input) should return dynamically either 0 or 1 or 2 or 3
The same Rand3(int input) should then return any value between 0 to 7.
Language is Core Java 1.5
Solution in Core Java Needed
Step1:
Rand3(int input){
//how do i return either 0,1,2,3 dynamically to Rand3() function
}
Step2:pass either 0,1,2,3 to same Rand3 function
Rand3(either 0,1,2,3)
// generate a number between 0 and 7
}