Contest Link import java.util.*; class Solution{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0){ String jewels = sc.next(); StringBuilder s = new StringBuilder(); s.append(jewels); int count = 0; while(true){ int temp = 0; for(int i=0;i<s.length()-1;i++){ if(s.charAt(i)==s.charAt(i+1)){ count++; ...
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
Comments
Post a Comment