Posts

Showing posts from April, 2020

BigInteger class in java

Image
BigInteger class in java BigInteger class in java comes with the java.math package. This class is used to store numbers which are beyond the capacity of other data types. If we want to store a number of 180 digits, it cannot be stored in another data type. So, BigInteger class is used to store these values. Implementation of BigInteger class in java :-  import java.math.BigInteger; class Main{     public static void main(String[] args){         BigInteger b = new BigInteger("1");         int n = 20;         for(int i=1;i<=n;i++){             b = b.multiply(BigInteger.valueOf(i));         }         System.out.println(f);     } } This program will print the factorial of 20 using BigInteger. Top computer books