BigInteger d = c.multiply(b.add(BigInteger.valueOf(2))); //d = c * (b + 2)
复制代码
案例
假设你被邀请参加抽奖活动,并从500个可能的数值中抽取60个,下面程序会告诉你中彩的概率是多少
[code]import java.math.BigInteger;import java.util.Scanner;/** * @author JKC * @Description: * @date 2022/6/29 09:42 */public class SixSample { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.println("你需抽多少次?"); int k = in.nextInt(); System.out.println("你能抽的最高数是什么?"); int n = in.nextInt(); BigInteger lotteryOdds = BigInteger.valueOf(1); for (int i = 1; i