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);
}
}
}
}
2 comments
hi! can you able to provide .net program
Yes.. sure