Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Prime number program

807598Feb 10 2006 — edited Feb 10 2006
Hi, i'm having a bit of trouble with a program im writing as homework assignment. So far i have

public class isPrime {
public isPrime() {
boolean nff;
int factor;
nff = true;

for( i=2; 2<N; i++){
factor =2;
while( nff && factor<= N){
if (N % factor == 0){
nff = false;
}else factor ++;
}
if( nff){
System.out.print(factor);

}

}

where i need some help is after the System.out.print, i need the program to count how many prime numbers have occured and then print the total number of primes out
i dont have any clue as to how i should increment this
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 10 2006
Added on Feb 10 2006
3 comments
412 views