18.4 Reimplementing Class FactorialCalculator Using Class BigInteger
Figure 18.4 reimplements class FactorialCalculator
using BigInteger
variables. To demonstrate larger values than what long
variables can store, we calculate the factorials of the numbers 0–50. Line 3 imports class BigInteger
from package java.math
. The new factorial
method (lines 8–15) receives a BigInteger
as an argument and returns a BigInteger
Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.