Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/purvgwtw/public_html/tutorials/common.php on line 7
Find Prime Numbers
Sponsered Links
Categories
Sponsered Links

Find Prime Numbers

Through the given code, we are finding the prime numbers between 1 to 100.

class PrimeNumbers{
public static void main (String args[]){
String primeNo = "";
int j=0;
System.out.println("Prime nums are:" );
for (int i = 1; i < 100; i++){ {
for ( j = 2; j < i; j++){
if (i % j == 0) {
break;
}
}
if (i == j) {
primeNo += i + " ";
}
}
}
System.out.println(primeNo);
}
}

Sponsered Links
Latest Updates
 
All Content of this site is for learning only. We do not warrant the correctness of its content. The risk from using it lies entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.
Copyright © 2014 PURVACOMPUTERS.COM All Right Reserved