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 to create constants in java?
What technique is carried out to find out if a particular string is empty?
What is the benefit of using enum to declare a constant?
What is the Concept of Encapsulation in OOPS
How many characters is 2 bytes?
What are the steps involved to create a bean?
Why does my function print none?
If a class is declared without any access modifiers, where may the class be accessed in java programming?
What is runtime polymorphism or dynamic method dispatch?
What is the function of http?
What is the use of :: in java?
What is get () in java?
How does a for loop work?
What is boolean example?
What is meant by interface?