uradio sam nekoliko ne znamu vemu je fora javlja mi gresku.
ako mozete pomozite mi hvala puno.
program treba da ispise proste brojeve od 2 pa do ukucucanog primjer 50.
od 2 do 50 treba da ispise sve proste brojeve..
Code:
public class osmani {
public static void main(String args[]){
int i, j, z;
int x = 50;
int[] feld = new int[x]; // feld wird erzeugt
for ( i = 0; i <= x-1; i++) // mit Werten von 1 bis x belegt
{
feld[i]=i+1;
}
for ( i = 2; i<=x/2; i++)
for ( j = 2; j<=x/2; j++){
feld[i *j]=0; }
System.out.println("Primzahlen sind.");
i = 0;
while(i <= x-1) {
if(feld[i] > 1) {
System.out.println("Primzahlen sind. "+ feld[i]);
}
i++;
}}}
public class osmani {
public static void main(String args[]){
int i, j, z;
int x = 50;
int[] feld = new int[x]; // feld wird erzeugt
for ( i = 0; i <= x-1; i++) // mit Werten von 1 bis x belegt
{
feld[i]=i+1;
}
for ( i = 2; i<=x/2; i++)
for ( j = 2; j<=x/2; j++){
feld[i *j]=0; }
System.out.println("Primzahlen sind.");
i = 0;
while(i <= x-1) {
if(feld[i] > 1) {
System.out.println("Primzahlen sind. "+ feld[i]);
}
i++;
}}}