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
How will you initialize an Applet?
Can constructor be static or final?
Can you access the private method from outside the class?
What is the difference between Java and C++?
What is polymorphism and what are the types of it?
Is a class subclass of itself?
What are three ways in which a thread can enter the waiting state in java programming?
What is the role of garbage collector in java?
How do you convert an int to a string in java?
Is node a data type in java?
What is the difference between int and integer in java?
What is super keyword explain with example?
How many types of array are there?
Can we create a constructor in abstract class?
Why stringbuffer is faster than string?