Results 1 to 3 of 3
  1. #1
    ATB
    ATB is offline Member
    Join Date
    Mar 2014
    Posts
    6
    Rep Power
    0

    Default calculate the factors of a positive integer number

    lines 7, 8, &12 "primes" are underline in red (prime cannot be resolved) is what pops up when i hover over the x's.
    i don't get why that is.
    Java Code:
    package assignment7;
     
    public class Exercise3 
    {
    	public static void main(String[] args) 
    	{
    		Prime.setSize(1000);
    		for (int p = Primes.next(); p < 30; p = Primes.next()) 
    		{
    			int n = (int)Math.round(Math.pow(2,p)) - 1;
    			System.out.printf("%d\t2^%d-1%d", p, p, n);
    		if (Primes.isPrime(n)) 
    		{
    			System.out.println(" is prime ");
    		} else 
    		{
    			System.out.println(" is not prime ");
    		}
    		}
    	}
    }
    Last edited by ATB; 03-17-2014 at 01:49 AM.

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,501
    Rep Power
    5

    Default Re: calculate the factors of a positive integer number

    What is Prime vs Primes? Perhaps you are missing an import statement. And in the future, please place your code
    between [code][/code] tags.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  3. #3
    jashburn is offline Senior Member
    Join Date
    Feb 2014
    Posts
    219
    Rep Power
    1

Similar Threads

  1. Replies: 1
    Last Post: 10-24-2012, 12:21 PM
  2. Replies: 2
    Last Post: 11-27-2011, 05:11 PM
  3. Replies: 11
    Last Post: 11-01-2011, 02:47 AM
  4. Testing whether a random number is positive
    By mamoonrizwan in forum New To Java
    Replies: 3
    Last Post: 05-07-2011, 08:58 AM
  5. Help with syntax to reverse a positive integer
    By sonny in forum New To Java
    Replies: 14
    Last Post: 02-27-2010, 06:19 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •