need help here to maybe convert long to BigDecimal or something. My solution to n=49, r=6 is 1 but is has to be 13983816.
need help here to maybe convert long to BigDecimal or something. My solution to
import java.math.BigDecimal; public class BinomialCoefficient { public static long factorial(int number) { long factorial = 1; for(int i = 1; i <= number; i++) { factorial *= i; } return factorial; } public static void main(String[] args) { int n = 49, r = 6; long nChooser; nChooser = factorial(n)/(factorial(r)*factorial(n-r)); //BigDecimal.valueOf(nChooser); System.out.println(nChooser); } }
https://stackoverflow.com/questions/67377535/java-trying-to-calculate-binomial-coefficient-with-implementing-big-decimal-my May 04, 2021 at 09:02AM
没有评论:
发表评论