Prime number generator

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Nepomuk
    Recognized Expert Specialist
    • Aug 2007
    • 3111

    #16
    Originally posted by mjslaugh
    This is the structure that I have so far. You can see what boolean condition that I am missing.

    inInt = kb.nextInt();

    for(int x = 0; x < inInt; x++){

    if( )\\not prime
    else
    System.out.prin t(x + " ");
    Well, the loop looks a bit weird, but I guess that's just because it's incomplete.
    Originally posted by mjslaugh
    The problem is that I can't figure out how to rule out if a number is prime other than checking divisibility of several numbers. Or should I embrace that idea and write a method that returns the boolean condition based on dividing several numbers??
    Sound's like it will work, doesn't it? And you can limit the amount of numbers, through which you divide... just think about it. :-)

    Greetings,
    Nepomuk

    Comment

    Working...