System.out.println("验证结果,概率相加之和为"+check);
}
private static BigInteger getOdds(Integer n,Integer k) {
BigInteger lotteryOdds = BigInteger.valueOf(1);
for(int i = 1; i<=k;i++) {
lotteryOdds = lotteryOdds.multiply(BigInteger.valueOf(n-i+1)).divide(BigInteger.valueOf(i));
}
return lotteryOdds;
}
}
结果:
run:
一等奖(中6+1)中奖概率:1/17721088=0.00000006
二等奖(中6+0):15/17721088=0.00000085
三等奖(中5+1)(3000元)中奖概率:162/17721088=0.00000914
四等奖(中5+0或4+1)(200元)中奖概率:7695/17721088=0.0004
五等奖(中4+0或3+1)(10元)中奖概率:137475/17721088=0.0078
六等奖(中2+1或1+1或0+1)(5元)中奖概率:1043640/17721088=0.0589
不中奖概率:16532100/17721088=0.9329
验证结果,概率相加之和为1.00001005
成功生成(总时间:0 秒)
祝大家中大奖,交好运!