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

write 3/5 with denominator 10 and 20​
A simple organism that has to compete for living space and food would have a greater chance of survival in a stable environment if it reproduced a.asexually
The predicted values were computed by using the line of best fit, y = 3.2x + 2. What are the residual values needed to complete the chart? a = b = c =
the top of lake is frozen as atmospheric temperature is -10 degree Celsius the temperature of the bottom of the lake is most likely to be??please give the answ
Can someone help out ??
algebra II engenuity
Q: If the average speed of a species of tortoise is 0.36 km/h, what is that speed in cm/s?
A line passes through the points (–1, –5) and (4, 5). The point (a, 1) is also on the line. whats a value?
what is the sum of the geometric sequence 2,10,50... if there are 8 terms?
Moritz is feeling hopeless and has very little energy. Which strategy can he use to cope with these problems interna starting a daily journal spending time with