Question: Homework in Java package labe; import java.util.Scanner Title : b > Lab e :( br Filename : b Sieve0fEratosthenes . java Date Written :/

Homework in Java

Homework in Java package labe; import java.util.Scanner " Title : b >

Lab e :( br Filename : b Sieve0fEratosthenes . java Date Written

:/ b Due Date :i b epy " cb> Description f b

package labe; import java.util.Scanner " Title : b > Lab e :( br Filename : b Sieve0fEratosthenes . java Date Written :/ b
Due Date :i b epy " cb> Description f b * Algorithm f b p " We start with a table of numbers,3,4 5 " cross off nunbers in the table until the only numbers left are prines . p +

Specifically , we begin with the first nurtar . p , n the table and and progressively 1. Declare p to be prine , then display it " 2. Cross off all the multiples of that number in the table starting fron 2 * 3. Find the next number in the table after p that is not yet crossed off and ' set p to that number and then repeat steps 1 to 3. * @author Your name and your partner s nane public class SieveofErstosthenes t public static void nain(Stringti args) i //Scanner Object used to get user input from console Scanner scanner - new Scanner(Systen.in); //Prorpt user to enter a number Systen out.print("Enter a nunber:") intn scanner.nextInt(): scanner.close( /Create table of nurbers according to n that user specified int table-new int[n]; yarray nate followed by Jength will eive us size of array, in this case it will be n int arraysize table.length int idx ; int nun -1 /Fill table with numbers while(idx

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!