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

Who is more responsible for the escalation of the cold war in cuba?
How do you find theme
________ of the population of the United States is obese.
What is being transported by the barge
What is the exact volume of the cylinder? A. 1728 mm3 B. 1728π mm3 C. 864 mm3 D. 864π mm3
Her eyes are heavy, She's tired of trying, Dreaming of a life which will never be hers, Because she doesn't believe she deserves, The love which you've offe
What is -√105 to the nearest integer and nearest tenth?
What is the latitude and longitude of Pass Christian,MS on a map?
A reaction that releases heat is what
Which best describes the underlined words in the sentence? Galileo, Copernicus, and Kepler were some of the early astronomers. A. complete subject B. co