Anonymous

How To Write A Program In Java To Find The Prime Number Between 1 To 100?

4

4 Answers

Anonymous Profile
Anonymous answered
Import java.io.*;class Prime{ public static void main(String a[]) { int n,I; for(n=1;n<=100;n++) { I=2; while(I<n) { if(n%I==0) { break; } I=I+1; } if(n==I) { System.out.print(n+ "  "); } } }}
Alongbar Daimary Profile
//Here is yout Program. But I've not Copiled it . Just see the logic
class prime{
public static void main(String[]ar){
System.out.println("Prime Numbers are:");
int res=0;
for(I=1;I<=100;I++)
{
  res= PrintPrime(I);
  if (res>0)
        System.out.print("t"+res);
}
}
int PrintPrime(int number){
for(int I=2;I<number;I++){
    if(number%I==0){
        prime=false;
        break;
    }
  else
      prime=true;
}
if (prime==false)
return 0;
else
return number;
}
}
vinitkar  Tripathi Profile
Class prime{public static void main(String arg[]){o:for(int I=1;I<=100;I++){for(int j=2;j<I;j++){if (I%j==0)continue 0;}System.out.print("Prime number is"+I);}}}
brijbihari rajouriya Profile
Class Num{
public static void main(String[]ar){
System.out.println("Prime Numbers are:");
int  r=0;
for(I=1;I<=100;I++)
{
   r= PrintPrime(I);
   if (r>0)
  System.out.print("t"+r);
}
}
int PrintPrime(int number){
for(int I=2;I<number;I++){
    if(number%I==0){
  prime=false;
  break;
    }
   else
  prime=true;
}
if (prime==false)
return 0;
else
return number;
}
}

Answer Question

Anonymous