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

question 6 please solve​
The ingredients for your braised greens cost 1.32. You sell it for $4. What is your contribution margin?
Students returning to a secondary school have to pass through a check point at the rate of 50 per though. The average time for checking is 35 seconds. The arriv
Find the longer and shorter lengths and hypotenuses
pleasee help with function graphing
3 . Rewrite each of these sentences in order not to change the original meaning 1 Chi and her husband invuted my family to their housew
Can somebody please answer asap for brainlist and correct answer?
hello guys, can you give me the answers​
What is the most therapeutic response to this client? a. “We can just order a Kosher meal here. It will be fine.” b. “We do not really have a place to keep fo
During which phase of the cell is a cells DNA copied