Code:
public class Prime_Number{
public static void main (String args[])
{
System.out.print("Prime numbers from 100 to 200\n");
int r;
for(int i=100;i<200;i++)\ {
int p=0;
for(int j=2;j<=(i/2);j++) {
r=i%j;
if(r==0) {
p=1;
break;
}
}
if(p==0)
System.out.println(i);
}
}
}
Output:
Prime numbers from 100 to 200101
103
107
109
113
127
131
137
139
149
151
157
163
167
173
179
181
191
193
197
199
No comments:
Post a Comment