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

Name 3 things that would be considered a compound.
Marta looked at the results for the USA in the 2004 summer Olympics and noticed that the number of silver medals was 6 ​fewer (less)​ than twice the number of b
In 1948 the USA did not accept the people republic of China as chinas true government true or false
2 Points Sara starts walking at noon at a speed of 4 miles per hour. Eddie leaves the same place an hour later and walks in the same direction at a speed of 5 m
How far can you lead off the base in softball?
geometry::: please help me ASAP
Carla ________ ir al recorrido por los lugares históricos de la ciudad.
Who is themistocles?
What are 2-3 helpful tips to remember when planning your labor & delivery?
There are 235 whistles and 42 bells in the store. Ryan counts 128 whistles on the shelf. How many whistles are not on the shelf