Author Topic: Java help  (Read 916 times)

i was only demonstrating how methods would work. i could've just done this

class SomeGayClass {
   public static void main(String[] args) {
      System.out.println("huehuehueheuheuehu");
   }
}

i'm aware

You can make it twice as efficient by only dividing by numbers less than half. If a number is more than half than it has to be multiplied by something between 1 and 2 to be equal to itself, which automatically makes it not a factor of the tested number.

yeah, i actually factored that in to my formula when i did it that short while ago, not sure why it slipped my mind now.

You can make it twice as efficient by only dividing by numbers less than half. If a number is more than half than it has to be multiplied by something between 1 and 2 to be equal to itself, which automatically makes it not a factor of the tested number.
use the square root of itself silly
anything greater than that is a repeat

also, what's the String[] args for?

it's how the program gets command arguments. e.g. if you type "programname 5" in the command prompt, args[1] would be 5.

my explanation: teacher put it in and it makes main method work so definitely essential for whatever reason nobody told me.

okay seriously how did they not teach you this stuff in third grade
Prime numbers have never come up in my 12 years of education.

I had to do this for my intro class, I just used

if( (n%2) == 1)
it's a prime

else
it's not prime

I had to do this for my intro class, I just used

if( (n%2) == 1)
it's a prime

else
it's not prime
bool p(int a){return n%2;}

Tiny version, some compiliers allow instant convesions from int to bool.
edit: this finds if it's odd or not





God dam it, I was linked this thread and forgot it was old.
« Last Edit: January 04, 2013, 11:45:27 PM by DrenDran »

i forgot what prime numbers are, lol.
This thread is now about how utterly handicapped Elecro is.