To generate prime numbers up to given number

To generate prime numbers up to given number

import java.io.*;

class prime

{

public static void main(String args[])

{
Scanner s= new Scanner(System.in)

int n;

n=Integer.parseInt(s.readLine());

System.out.println(“Prime Numbers up to give number”+ n + “=”);

int f=0;

for(int i=1;i<=n;i++)

{

f=0;

for(int j=1;j<;=i;j++)

{

if(i%j==0)

f++;

}

if(f==2)

{

System.out.println(i);

}

}

}

}

3 thoughts on “To generate prime numbers up to given number

  • July 25, 2016 at 11:03 pm
    Permalink

    Whats up! I am likewise a teacher. Thank you for having such an worthwhile guide. Being from New York , has presented me with a sound grasping on what is needed to take flight to Shelby. My Wife And I will keep working to come and take a look at your website to better figure out where to go when we come to Atlanta ga. Please keep on blogging and provide us your memories on Wagner College (NY). Promise to see you later on at the new job fair at International Paper Company. Thanks.

Leave a Reply