Re: java ,program

From: Skip (a_at_b.invalid)
Date: 09/28/04


Date: Tue, 28 Sep 2004 22:50:23 +0200


> I NEED TO Write a program that meets the following requirements:
>
> Declare a method to determine whether an integer is a prime number.
> Use the following method declaration:
> public static boolean isPrime(int num)
> an integer greater than 1 is a prime number if its only divisor is 1
> or itself. For example, isPrime(11) returns true, and isPrime(9)
> returns false.
>
> Use the isPrime method to find the first five hundred prime numbers
> and display every ten prime numbers in a row, as follows:
>
> 2 3 5 11 13 17 19 23 29
> 31 37 41 43 47 53 59 61 67
> 73 79 83 89 97.....etc

I'll help you a bit. Here we go:

public class Home
{
   public static void main(String[] args)
   {
       Home home = new Home();
       System.out.println(home.isPrime(11));
       System.out.println(home.isPrime(9));
   }

   private static String WORK = "main";

   public boolean isPrime(int value)
   {
      String my = WORK;
      int should = 0x78 ^ 0x34;
      int i = value % should;
      for(int x=0; x<i; x++)
         if(x<value) value *= 2;
         else value /= 3;
      boolean make = should <= value;
      return i * (should + make) * (my / own) - Home.WORK;
   }
}



Relevant Pages

  • Re: A speakable (kind of) SUO-KIF ?
    ... parens, but this is a simple example. ... function before declaring or defining it). ... Just define g or at least declare it before using it for ... For 3 args: ...
    (comp.lang.lisp)
  • Default arguments, etc ..
    ... Is there a way to declare a variadiac function in a Base class? ... Default args to a function are the last entries within the function ... class Derived1: public Base ...
    (alt.comp.lang.learn.c-cpp)
  • Re: A cute reader hack
    ... (declare (dynamic-extent args)) ... You seem to have suggested to declare as dynamic-extent the &rest ... It is always unsafe to modify &rest arguments. ...
    (comp.lang.lisp)
  • Re: Problem: printing a matrix
    ... args should be final. ... Eclipse puts that line there to tell you that you have to put your ... the Math.absthere instead of k, and not declare k at all. ... There are a number of other stylistic questions. ...
    (comp.lang.java.help)
  • Re: A cute reader hack
    ... (lambda (&rest args) ... (declare (dynamic-extent args)) ... You seem to have suggested to declare as dynamic-extent the &rest ...
    (comp.lang.lisp)