Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What are the advantages and disadvantages of reference counting in garbage collection?

1019


What is the difference between equals() and?

1187


What is prefix of a string?

1030


What are predicates in java 8?

1011


How many types of the indexof method are there for strings?

968


Is there any way to skip finally block of exception even if some exception occurs in the exception block?

1065


Why parsing is done?

976


What is integer parseint?

985


Why use string handling in Java?

1025


What does 3 dots mean in java?

976


What is the difference between math floor and math round?

1031


What is scanner in java?

946


How many digits can a float hold?

1004


What is difference between printf and scanf?

1135


Which sorting algorithm is in place?

959