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 are the advantages and disadvantages of reference counting in garbage collection?
What is the difference between equals() and?
What is prefix of a string?
What are predicates in java 8?
How many types of the indexof method are there for strings?
Is there any way to skip finally block of exception even if some exception occurs in the exception block?
Why parsing is done?
What is integer parseint?
Why use string handling in Java?
What does 3 dots mean in java?
What is the difference between math floor and math round?
What is scanner in java?
How many digits can a float hold?
What is difference between printf and scanf?
Which sorting algorithm is in place?