first commit

This commit is contained in:
2021-04-14 16:00:09 +05:30
commit 430dfcee8b
16 changed files with 574 additions and 0 deletions

25
PrimeNoStatic.java Normal file
View File

@@ -0,0 +1,25 @@
// Program to display first n Prime number (Static Method).
class PrimeNoStatic {
public static void main(String args[]) {
int n;
int status = 1;
int num = 3;
System.out.println("First 100 prime numbers are:");
System.out.println(2);
for ( int i = 2 ; i <=100 ; ) {
for ( int j = 2 ; j <= Math.sqrt(num) ; j++ ) {
if ( num%j == 0 ) {
status = 0;
break;
}
}
if ( status != 0 ) {
System.out.println(num);
i++;
}
status = 1;
num++;
}
}
}