I am supposed to make a class PrimeNumberGenerator
which has a method nextPrime
that will print out all prime numbers up to a number the user input
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.xml.soap.Node;
public class mainone {
public static void main(String args[]){
int[] primenumber=new int[13];
for(int a=2,j=0;a<=14;a++,j++){
primenumber[j]=a;
}
for(int b=1;b<13;b++){
int d=primenumber[b];
if(d%2==0){
primenumber[b]=0;
}
for(int c=2;c<13;c++){
int e=primenumber[c];
if(e>0){
for(int f=c+1;f<13;f++){
int g=primenumber[f];
if((g>0)&(g%e==0)){
primenumber[f]=0;
}
}
}
}
}
for(int j=0;j<13;j++){
System.out.println(primenumber[j]);
}
}
}