Author Topic: Java help  (Read 702 times)

I want to make a prime number method (it identifies all prime numbers btwn 0 and the parameter)
But I forgot how to set it up
How do I write up a method?
How do I set up the main method majigger?

i forgot what prime numbers are, lol.

i forgot what prime numbers are, lol.
a number that can only be divided by 1 and itself without a remainder. e.g 7, 13, 17

so basically odd numbers?

so basically odd numbers?
nope.
15 can be divided by 5 and 3 for example.


i forgot what prime numbers are, lol.
how

so basically odd numbers?
what the f

OT: I don't know.
okay seriously how did they not teach you this stuff in third grade



OT: i did this for my IT class not too long ago, something like this:

static boolean isPrime(int num) {
   for (int n2 = 2; n2 < num - 1; n2++) {
      if (n1%n2 == 0){
         return false;
      }
   }
   return true;
}

it checks every number except 1 and the number given and sees if the remainder of the division of the two numbers is 0. if it finds any number that is evenly divisible without a remainder, it returns false, otherwise returns true.

this might not work though, i'd need to open the project up in eclipse or something to be sure of its functionality.
« Last Edit: December 29, 2012, 07:25:18 PM by Kingdaro »

i did learn in 4th grade, and that was like 5 years ago.

how
what the f
okay seriously how did they not teach you this stuff in third grade



OT: i did this for my IT class not too long ago, something like this:

static int isPrime(int num) {
   for (int n2 = 2; n2 < num - 1; n2++) {
      if (n1%n2 == 0){
         return false
      }
   }
   return true
}

it checks every number except 1 and the number given and sees if the remainder of the division of the two numbers is 0. if it finds any number that is evenly divisible without a remainder, it returns false, otherwise returns true.

this might not work though, i'd need to open the project up in eclipse or something to be sure of its functionality.
uh, i didn't want an answer, i just wanted to know how to preface my program. (e.g setting up the main method, all those import shenanigans)

oh, i think i see what you're saying


class SomeGayClass {
   static String someGayMethod() {
      return "huehuehueheuheuehu";
   }

   public static void main(String[] args) {
      System.out.println(someGayMethod());
   }
}


like this?

and for something like this, you don't really need to import much, if anything at all.

i did learn in 4th grade, and that was like 5 years ago.
so, your in high school but don't know what a prime number is?

oh, i think i see what you're saying


class SomeGayClass {
   static String someGayMethod() {
      return "huehuehueheuheuehu";
   }

   public static void main(String[] args) {
      System.out.println(someGayMethod());
   }
}


like this?

and for something like this, you don't really need to import much, if anything at all.
yes like that. thanks.

so, your in high school but don't know what a prime number is?

in high school next year.

Code: [Select]
class wooble {
public static void main(String[] args) {
System.out.println("Open the door get on the floor")
}
}
is a much shorter way

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");
   }
}