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 two parts that are sometimes made of hard metal and pressed into the head​
What are the x- and y-intercepts of y=-3x -9?
Me m.olesta que la gente ________________ las normas culturales. A. malinterpretan B. malinterpreten C. malinterpreta D. malinterprete
Find an ordered pair to represent t in the equation t=1/2u+v if u=(-1,4) and v=(3,-2)
which kinds of organisms use photosynthesis?
While researching a thesis paper on Ronald Reagan’s presidency, you discover multiple resources that support your argument. Which resource would be the most val
Find the measure of the remote exterior angle.
The following table shows the number of feet a bird flies above the ground as a function of time: (In the picture) Find and interpret the meaning of the x-inter
what is the weight of dark matter​
Which of the following factors could you change in a system and not change its induced EMF? A. magnetic field B. type of wire C. velocity of the wire D. len