- 0
Notifications Mark All Read
- Login
- Get Prime
Problem 25
Access Denied!
To view this page you have to login first
Login here -
Trivia
Did you know 1 million people use PrepInsta everyday?
Notifications Mark All Read
To view this page you have to login first
Login here -
Did you know 1 million people use PrepInsta everyday?
import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
int i,j;
System.out.println(“Enter a limit”);
int n=in.nextInt();
System.out.print(“2 “);
for(i=3;i<=n;i++)
{
int count=0;
for(j=1;j<=i;j++)
{
if(i%j==0)
count++;
}
if(count==2)
System.out.print(i+" ");
}
}
}