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

What does method mean?

746


Does java support Operator Overloading?

830


Which package has light weight components?

773


List some important features of java 10 release?

731


How will you print number in reverse (descending) order in BST.

772


What are the different http methods?

740


How do you sort in java?

783


What is nested class?

764


What is difference between hashset and hashmap?

800


What is bytecode verifier?

705


What is parsing and its types?

784


What is communist flag?

771


What is the importance of static variable?

803


What does system.gc() and runtime.gc() methods do?

817


What are the restrictions that are applied to the java static methods?

767