java program that takes a 3 digit number n and finds out
whether
the number 2^n + 1 is prime, or if it is not prime find out
its
factors.

Answer Posted / vipul

public List checkPrime(int N) {
boolean isPrime = true;
List<Integer> list = new ArrayList<Integer>();
int p = 7;
for (int i = 2; i < p; i++) {
if (p % i == 0) {
isPrime = false;
list.add(i);

} else
isPrime = true;
}
if (isPrime) {
list.add(p);
}
return list;
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how to create constants in java?

612


What technique is carried out to find out if a particular string is empty?

578


What is the benefit of using enum to declare a constant?

661


What is the Concept of Encapsulation in OOPS

562


How many characters is 2 bytes?

536






What are the steps involved to create a bean?

685


Why does my function print none?

524


If a class is declared without any access modifiers, where may the class be accessed in java programming?

663


What is runtime polymorphism or dynamic method dispatch?

526


What is the function of http?

536


What is the use of :: in java?

572


What is get () in java?

574


How does a for loop work?

512


What is boolean example?

533


What is meant by interface?

568