Untitled 2 - ); String biggestNumberString =...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
import  java.util.Scanner; public   class  SieveOfEratosthenes { public   static   boolean  isPrime( double  number){ if ((number== 0)|(number==1)){ return   false ;} for ( int  divisor = 2; divisor <= Math.sqrt(number); divisor+ +){ if  (number % divisor == 0){ return   false ; } } return   true ; } public   static   void  main(String[] args) { Scanner scanner =  new  Scanner(System. in ); System. out .print( "Input number to check for primeness "
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ); String biggestNumberString = scanner.nextLine(); double biggestNumber = Double.parseDouble(biggestNumberString); boolean sieve = new boolean [( int ) (biggestNumber + 1)]; for ( int index = 0; index &lt; sieve. length ; index++){ System. out .print( &quot;\n&quot; + index + &quot; &quot; + isPrime(index)); } } }...
View Full Document

This note was uploaded on 12/03/2009 for the course IAS 2045 taught by Professor Kent during the Spring '09 term at Arkansas State.

Ask a homework question - tutors are online