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 does method mean?
Does java support Operator Overloading?
Which package has light weight components?
List some important features of java 10 release?
How will you print number in reverse (descending) order in BST.
What are the different http methods?
How do you sort in java?
What is nested class?
What is difference between hashset and hashmap?
What is bytecode verifier?
What is parsing and its types?
What is communist flag?
What is the importance of static variable?
What does system.gc() and runtime.gc() methods do?
What are the restrictions that are applied to the java static methods?