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 is the purpose of the finally clause of a try-catch-finally statement in java programming?

733


How to create a base64 decoder in java8?

813


Which package is imported by default?

855


What is increment in java?

760


What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class hierarchy?

898


How many types of java are there?

774


How to invoke external process in java.

810


What are thread local variables?

794


What is api in java?

778


How do I type unicode?

749


Can two objects have same hashcode?

774


Can we make main() thread as daemon?

856


How many ways can we create singleton class?

748


Is a method a procedure?

797


how to create multithreaded program? Explain different ways of using thread? : Java thread

763