Java BigInteger

Sort by

recency

|

354 Discussions

|

  • + 0 comments
    import java.io.*;
    import java.util.*;
    import java.math.*;
    
    public class Solution {
    
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            
            BigInteger a = sc.nextBigInteger();
            BigInteger b = sc.nextBigInteger();
        
            sc.close();
            
            System.out.println(a.add(b));
            System.out.println(a.multiply(b));
        }
    }
    
  • + 0 comments
    import java.io.*;
    import java.util.*;
    import java.text.*;
    import java.math.*;
    import java.util.regex.*;
    
    public class Solution {
    
        public static void main(String[] args) {
            /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
            Scanner sc = new Scanner(System.in);
            BigInteger valueA = new BigInteger (sc.next());
            BigInteger valueB = new BigInteger (sc.next());
            
            sc.close();
            
            System.out.println(valueA.add(valueB));
            System.out.println(valueA.multiply(valueB));
        }
    }
    
  • + 0 comments

    Here's using BufferedReader

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String num1 = br.readLine().trim();
            String num2 = br.readLine().trim();
            br.close();
            BigInteger n1 = new BigInteger(num1);
            BigInteger n2 = new BigInteger(num2);
            System.out.println(n1.add(n2));
            System.out.println(n1.multiply(n2));
    
  • + 0 comments

    Scanner scan = new Scanner(System.in); BigInteger a = new BigInteger(scan.nextLine()); BigInteger b = new BigInteger(scan.nextLine()); System.out.println(a.add(b)); System.out.println(a.multiply(b));

  • + 0 comments

    public class Solution {

    public static void main(String[] args) {
    
        Scanner sc= new Scanner(System.in);
       BigInteger x=new BigInteger(sc.next());
       BigInteger y=new BigInteger(sc.next());
      System.out.println( x.add(y));
      System.out.println(x.multiply(y));
    
    }
    

    }