Output:
Click Here For Java Online Compiler
Solution:
*** First 10 Prime Numbers *** First 10 prime numbers are: 2 3 5 7 11 13 17 19 23 29
Click Here For Java Online Compiler
Solution:
public class First10PrimeNumbers { public static void main(String args[]) { int n; int status = 1; int num = 3; System.out.println("*** First 10 Prime Numbers ***" + "\n"); System.out.println("First 10 prime numbers are:"); System.out.println(2); for (int i = 2; i <= 10;) { for (int j = 2; j <= num / 2; j++) { if (num % j == 0) { status = 0; break; } } if (status != 0) { System.out.println(num); i++; } status = 1; num++; } } }
comment 1 comments:
more_vert
29 August 2018 at 20:04It is nice article to improve my knowledge.thank you for sharing useful post
visit
web programming tutorial
welookups
sentiment_satisfied Emoticon