We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I used
for (double j=1;j<=N;j++) {
BigDecimal num = new BigDecimal(Math.pow(N, j));
BigDecimal din = new BigDecimal(Math.pow(j, j));
BigDecimal cp = num.divide(din,MathContext.DECIMAL128);
if(cp.compareTo(max) == 1) {
max = cp;
k=j;
}
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #183: Maximum product of parts
You are viewing a single comment's thread. Return to all comments →
I used for (double j=1;j<=N;j++) { BigDecimal num = new BigDecimal(Math.pow(N, j)); BigDecimal din = new BigDecimal(Math.pow(j, j)); BigDecimal cp = num.divide(din,MathContext.DECIMAL128);