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
What is the purpose of the finally clause of a try-catch-finally statement in java programming?
How to create a base64 decoder in java8?
Which package is imported by default?
What is increment in java?
What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class hierarchy?
How many types of java are there?
How to invoke external process in java.
What are thread local variables?
What is api in java?
How do I type unicode?
Can two objects have same hashcode?
Can we make main() thread as daemon?
How many ways can we create singleton class?
Is a method a procedure?
how to create multithreaded program? Explain different ways of using thread? : Java thread