import java.util.Scanner;
public class Test
{
public static void main(String[] args) {
System.out.println("Enter the limit uptoo which you want to print prime no.");
int in = new Scanner(System.in).nextInt();
int limit =in;
for (int i = 2; i <=limit; i++) {
if(isprime(i))
{
System.out.println(i);
}
}
}
public static boolean isprime(int l)
{
for (int j = 2; j <l; j++) {
if(l%j == 0)
{
return false;
}
}
return true;
}
}
Post a Comment