Problem 25

One comment on “Problem 25”


  • Tahir khan

    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+" ");
    }
    }
    }