Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: how to find all the prime no. in 1000?

  1. #1
    Junior Member
    Join Date
    Nov 2013
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default how to find all the prime no. in 1000?

    becasue prime no. is a no. aliquant by a no. among 2 and itself.
    i want use a for statement, and use A to devide by (2,A), if A divisible by any no. in (2,a), A is not a prime.

    int i,a,c;
    for(a=2;a<1000;a+){
    for(i=2;i<a; ){
    while(c=a%i){i++}
    }System.out.println();
    }
    it's wrong.
    pls help. i don't know why, i have no clue. totely no clue!
    help!


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: how to find all the prime no. in 1000?

    What's wrong about it?

    PS- When posting code, please use the highlight tags and post code as an SSCCE.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Nov 2013
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: how to find all the prime no. in 1000?

    I have repost the code.

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: how to find all the prime no. in 1000?

    What's wrong about it?

    PS- When posting code, please use the highlight tags and post code as an SSCCE.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. [SOLVED] displaying every 1000 comparisons in merge sort
    By mia_tech in forum What's Wrong With My Code?
    Replies: 6
    Last Post: May 27th, 2012, 07:26 PM
  2. Find prime nums from 1-100 algorithm
    By The-EyE in forum What's Wrong With My Code?
    Replies: 2
    Last Post: February 5th, 2012, 11:39 PM
  3. Win 1000$ now [Java WebApp]
    By biz in forum Paid Java Projects
    Replies: 3
    Last Post: November 2nd, 2011, 11:05 AM
  4. The sum and product of a positive number between 1000 and 9999.
    By metaleddie13 in forum Member Introductions
    Replies: 1
    Last Post: September 15th, 2011, 04:39 AM
  5. composite and prime
    By cutee_eyeh in forum Object Oriented Programming
    Replies: 3
    Last Post: October 13th, 2010, 09:01 PM