Tomorrow Is Another Day
Either travel, either reading, body and soul must be one on the road
Pages
Home
COMP
Tech Links
Wednesday, 23 November 2016
Program to print prime numbers in java
public class primenumbers {
public static void main(String[] args) {
int num=50;
int count=0;
for(int i=2;i<=num;i++){
count=0;
for(int j=2;j<=i/2;j++){
if(i%j==0){
count++;
break;
}
}
if(count==0){
System.out.println(i);
}
}
}
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment