Prime number checker using Java
By : Pawan Sharma
Date : March 29 2020, 07:55 AM
I wish did fix the issue. Your problem is int overflow. 2147483647 is the maximum value for int. This data type can't store larger numbers. Double should be used for floating numbers. code :
BigInteger a = new BigInteger("1024"); // creates BigInteger representing number 1024.
BigInteger b = new BigInteger(1024); //also creates BigInteger representing number 1024.
BigInteger c = new BigInteger("10000000000", 2); //also creates BigInteger representing 1024
if (a.equals(b)) {...}
BigInteger c = a.add(b);
//or
a = a.add(b);

Prime number in java 8
By : user6933210
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , IntStream can be used to generate integer stream code :
public static boolean isPrime(int number) {
return !IntStream.rangeClosed(2, number/2).anyMatch(i > number%i == 0);
}
public static boolean isPrime(int number) {
return IntStream.rangeClosed(2, number/2).noneMatch(i > number%i == 0);
}

My code works fine but every time the input is a prime number it keeps on printing "This is a prime number." o
By : KamehK
Date : March 29 2020, 07:55 AM

Generating relative Prime number of a user defined prime number?
By : Rajesh A
Date : March 29 2020, 07:55 AM
With these it helps If you want to find the next smallest relative prime, then I think you need to loop from the user's inputted number (e.g. if users input 3, then you need to loop from 4), and then check whether that number is relatively prime. To check whether two numbers are relatively prime, you can use gcd, and one very famous algorithm to do this is to use Euclid's algorithm. You don't need to include a specific library, it's basically just looping and doing modulo. Take a look at this link.

Prime Number in java
By : Aaron Paul
Date : March 29 2020, 07:55 AM

