Pages

Java program to print prime numbers


import java.util.Scanner;
class prime
{
 public static void main(String[] args)
 {
  int n,p;
  Scanner s=new Scanner(System.in);
  System.out.println(“Enter upto which number prime numbers are needed”);
  n=s.nextInt();
  for(int i=2;i<n;i++)
  {
   p=0;
   for(int j=2;j<i;j++)
   {
    if(i%j==0)
    p=1;
   }
   if(p==0)
    System.out.println(i);
  }
 }
}

4 comments:

  1. Wow, this paragraρh is good, my siѕter is аnalуzing such things, thus Ӏ
    am gоing to infοrm her.

    Here is my blοg - eine günstige Suchmaschienen-Optimierung für Mainz Centrum

    ReplyDelete
  2. This is the right web site for anybody who wishes to understand this topic.
    You know so much its almost hard to argue with you (not that I actually will
    need to…HaHa). You definitely put a new spin on
    a topic that's been written about for decades. Excellent stuff, just wonderful!

    Here is my site best way to lose weight fast

    ReplyDelete
  3. What's up every one, here every person is sharing these kinds of experience, so it's good to read this website, and
    I used to pay a visit this web site all the time.


    Feel free to visit my web blog - Best Weight Loss Product

    ReplyDelete
  4. You could definitely see your skills within the work you write.
    The arena hopes for more passionate writers such as you
    who are not afraid to mention how they believe. All the time go after your heart.


    Feel free to visit my weblog; Pureberry Max Raspberry Ketone REview

    ReplyDelete