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
Why is the singleton pattern considered to be an anti pattern?
How can we make copy of a java object?
Explain java coding standards for methods?
Why heap memory is called heap?
what is the swingutilities.invokelater(runnable) method for? : Java thread
What are memory tables?
What are the advantages of unicode?
Why java does not support pointers?
How many bits is a string in java?
What access modifiers can be used for class ?
What are the new features in java 8? Explain
What are the two types of exceptions in java? Which are the differences between them?
What are the parts of methodology?
What is Java Annotations?
Howto get an object that will perform date & time calculations then format it for output in some different locales with different date style.can ne1 tel me the answer of this question.pls