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

X +y=3 and 2x +3y=-4
What force would have been applied to the bus from t=16 s to t=21 s? Assume the mass of the bus was 50 kg.
a³-a²b-ab²+b³hihihihihihihi
write linear equatuon relating x and y for each table x (2,4,6,8). y (5,8,11,14)
pls help me with this if you can
Can you plssssssssssss help meCan you do plsssssssss help meeee
the british parliament passed the coercive act and the quebec act in response to which event ?
47 is 0.5% of what number Please answer this fast I'll mark you as brainliest. Thank You.
Mrs. James needs to have her Jeep repaired but does not want to spend more than $375 for the repairs. The mechanic says that the part needed for the repair will
1) Find the value of x 2) Justify your answer by explaining the series of angle relationships used to prove the value of x.