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

An essay is a. a subgenre of fiction in which authors tend to employ experimental techniques. b. a poetic and often dramatic type of writing that can sometime
Explain how our freedoms help people become more effective and knowledgeable citizens.
Find an equation for the line that passes through the point (-3, 6), parallel to the line through the points (0,-7) and (4,-15). Write your answer in point-slop
¿B o V? Choose which letter completes the word. __uelo a.b b.v Please select the best answer from the choices provided
4/5 x g = 2/5 what is g
help cant figure out which ones right
What is the value of 5 in 43.245
The angles of a triangle are 30º, 60º, and xº. What is the value of x? x =
What percentage of tommy's coins are dimes?
1. What image in the words “burn and rave” suggest? Why should someone “burn and rave at close of day?” Do not go gentle into that good night, Old age should bu