From 90fde363ff9adc4902d12e20446700fc536115c8 Mon Sep 17 00:00:00 2001 From: Ankita Sharma <30744863+ankitasharma88990@users.noreply.github.com> Date: Wed, 7 Oct 2020 17:39:04 +0530 Subject: [PATCH] Java Big numbers --- PrimeBigNumber.java | 30 ++++++++++++++++++++++++++++++ javaBigInteger.java | 21 +++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 PrimeBigNumber.java create mode 100644 javaBigInteger.java diff --git a/PrimeBigNumber.java b/PrimeBigNumber.java new file mode 100644 index 00000000..07a20381 --- /dev/null +++ b/PrimeBigNumber.java @@ -0,0 +1,30 @@ +import java.io.*; +import java.math.*; +import java.security.*; +import java.text.*; +import java.util.*; +import java.util.concurrent.*; +import java.util.*; + +public class PrimeBigNumber { + + + + private static final Scanner scanner = new Scanner(System.in); + + public static void main(String[] args) + { + String n = scanner.nextLine(); + BigInteger bn=new BigInteger(n); + if(bn.isProbablePrime(1)) + { + System.out.println("prime"); + } + else + { + System.out.println("not prime"); + } + scanner.close(); +} + +} diff --git a/javaBigInteger.java b/javaBigInteger.java new file mode 100644 index 00000000..87b2528d --- /dev/null +++ b/javaBigInteger.java @@ -0,0 +1,21 @@ +import java.io.*; +import java.util.*; +import java.text.*; +import java.math.*; +import java.util.regex.*; + +public class javaBigInteger { + + public static void main(String[] args) { + Scanner sc=new Scanner(System.in); + BigInteger b1=new BigInteger(sc.next()); + BigInteger b2=new BigInteger(sc.next()); + + BigInteger b3,b4; + b3=b1.add(b2); + b4=b1.multiply(b2); + + System.out.println(b3); + System.out.println(b4); + } +}