Tuesday, August 31, 2010
Java : List Prime Numbers between 1 to Given Number
import java.io.*;
class AllEvenNum{
public static void main(String[] args) {
try{
BufferedReader br1 = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a Number : ");
int num = Integer.parseInt(< /span>br1.readLine());
System.out.println("Even Numbers are:");
for (int i=1;i <=num ; i++){
if(i%2==0 ){
System.out.print(i+",");
}
}
}
catch(Exception e){}
}
}
List prime numbers
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment