I've been using the BigDecimal
type instead of the double
, but I have hit a bit of a roadblock—the square root.
Don't take the square root of each term. As shown in this example, add the terms of the series, which has the exact sum π2/6. When your loop terminates, multiply by six and then take a single square root.