Java BigInteger

Sort by

recency

|

346 Discussions

|

  • + 0 comments

    import java.io.; import java.util.; import java.util.Scanner; import java.math.BigInteger; 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 a = sc.nextBigInteger();
            BigInteger b = sc.nextBigInteger();
            BigInteger sum, mul;
            sum = a.add(b);
            mul = a.multiply(b);
            System.out.println(sum + "\n" + mul);
    }
    

    }****

  • + 0 comments
    
    

    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 a = new BigInteger(sc.nextLine());
        BigInteger b = new BigInteger(sc.nextLine());
         BigInteger sum = a.add(b);
          BigInteger prod = a.multiply(b);
    
        System.out.println(sum+"\n"+prod);
    }
    

    }

  • + 0 comments

    Scanner sc=new Scanner(System.in); BigInteger b1=sc.nextBigInteger(); BigInteger b2=sc.nextBigInteger(); BigInteger sum=b1.add(b2); BigInteger mul=b1.multiply(b2); System.out.println(sum); System.out.println(mul);

    }
    

    }

  • + 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) {
        Scanner sc = new Scanner(System.in);
        BigInteger bigInt1 = sc.nextBigInteger();
        BigInteger bigInt2 = sc.nextBigInteger();
        BigInteger sum = bigInt1.add(bigInt2);
        BigInteger product = bigInt1.multiply(bigInt2);
        System.out.println(sum);
        System.out.println(product);
    }
    

    }

  • + 0 comments

    import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger;

    public class BigIntegerJava {

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String a = reader.readLine();
        String b = reader.readLine();
    
        BigInteger num1 = new BigInteger(a);
        BigInteger num2 = new BigInteger(b);
    
        //addition
        //abstract negatives
        BigInteger addition = num1.abs().add(num2.abs());
        System.out.println(addition);
    
        //multiplication
        //abstract negatives
        BigInteger product = num1.abs().multiply(num2.abs());
        System.out.println(product);
    }
    

    }