java
/**
* LeetCode470_用Rand7()实现Rand10()
*/
public class LeetCode470 extends SolBase {
public int rand10() {
int temp = 40;
while (temp >= 40) {
temp = (rand7() - 1) * 7 + rand7() - 1;
}
return temp % 10 + 1;
}
}
解题思路分析过程: