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
Does java set allow duplicates?
What is <> used for in java?
How to make a write-only class in java?
Are global variables initialized to zero?
What is lastindexof in java?
What is the difference between dom and sax parser in java?
Explain spliterator in java8?
Can singleton class be serialized?
What does provide mean construction?
How many types of equations are there?
What is adapter in java?
What is the purpose of return statement?
What are synchronized methods and synchronized statements in java programming?
What is vector capacity in java?
Explain the different forms of polymorphism?