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 constructor return any value?
Can we sort arraylist in java?
Is map sorted in java?
How many types of assembly languages are there?
What does string intern() method do?
What are the different types of inheritance in java?
What is encapsulation in java?
List out benefits of object oriented programming language?
What do you understand by a Static Variable?
Difference between stack and queue?
Does a function need a return?
What happens if a constructor is declared private?
Write a program to print all permutations of string?
What is the purpose of the strictfp keyword?
Is vector ordered in java?