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

A department store purchases a dress for $80. To sell the dress to customers, the price is marked up by 19%. You hand the clerk $110. How much change will you
elevated blood cell count can be a result of: A. bacterial infection B. viral infection C. parasitic infection D. immune hypersensitivity/ allergic reactions E.
. If a human has not eaten in 6 days,
A patient received a new heart transplant, but shows signs of graft rejection after 2 weeks. Which type of hypersensitivity reaction is in progress?" a) Type I
0-4+7-5×3÷9×5-4 do the sum of that mathematics...
the expression 4X gives the perimeter of a square with a side length of X units. what is the perimeter of a square with a side length of 5/7 units?
1. Obligate anaerobes are often grown in an anaerobe jar, which completely excludes oxygen from the environment. How is the environment within a tube of fluid t
how to solve these questions?
How many cm has a inch
is gravity a field force