Re: java ,program
From: Skip (a_at_b.invalid)
Date: 09/28/04
- Next message: Fredrik: "Execute external program from tomcat servlet"
- Previous message: Bryce: "Re: Simple type conversion question"
- In reply to: Benjamin: "java ,program"
- Next in thread: hilz: "Re: java ,program"
- Reply: hilz: "Re: java ,program"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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;
}
}
- Next message: Fredrik: "Execute external program from tomcat servlet"
- Previous message: Bryce: "Re: Simple type conversion question"
- In reply to: Benjamin: "java ,program"
- Next in thread: hilz: "Re: java ,program"
- Reply: hilz: "Re: java ,program"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|