nelsonaustin8179 nelsonaustin8179
  • 23-06-2019
  • Computers and Technology
contestada

Write a JAVA program to generate the list of prime numbers between 100 and 1000 ?

Respuesta :

Аноним Аноним
  • 23-06-2019

First of all, we will need a function that checks if a number is prime or not:

boolean isPrime(int n){

 for(int i=2; i<=math.sqrt(n); i++){

   if(n % i == 0) return false;

 }

 return true;

}

Then, in the main program, we will call this function with all the desired inputs, and we will print the prime numbers:

for(int n=100; n<= 1000; n++){

 if(isPrime(n)) print(n);

}

Answer Link

Otras preguntas

determine mass of water formed when 12.5 L NH3(at298K and 1.50atm) is reacted with 18.9L of O2 (at 323K and 1.1atm)
Identify each of the following equations as which type of chemical reaction? C12 + Nal —- NaCL + 12
Why is entropy negative for ring closures? a. closing a ring results in fewer molecules. b. closing a ring results in more molecules. c. closing a ring releases
my Question is find the x-intercept of following equation.simplify your answer 15x+-4y=20
I need some help here I'm not sure what to do. Thanks in advance.
The domain of {(-4, 0), (-2, 1), (1, 3), (2, 6)} is {-4, -2, 1}. a. all real numbers b. x is greater than or equal to 7 c. x is less than or equal to 7 d. x is
Why did the kangaroo see a psychiatrist worksheet answers?
What would the consequence of deleting telomerase from a human cell line?
A year before the fourteen points speech, president wilson said a peace agreement should?
What role does environment have on impulsivity according to gottfredson and hirschi?