Skip to content

Instantly share code, notes, and snippets.

@mariiaKolokolova
Created April 30, 2020 20:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mariiaKolokolova/c0b2846705cf8f505f26d4f73ab2ceb0 to your computer and use it in GitHub Desktop.
Save mariiaKolokolova/c0b2846705cf8f505f26d4f73ab2ceb0 to your computer and use it in GitHub Desktop.
package maricka.kolokolova;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
int st = 1;
int end = 100;
int ch = 0;
System.out.println("Prime numbers: ");
for (int i = st; i <= end; i++) {
ch = 0;
if (i == 1) {
ch = 1;
continue;
}
for (int j = st; j <= end; j++) {
if (j != 1 && j != i) {
if (i % j == 0) {
ch = ch + 1;
break;
}
}
}
if (ch == 0) {
System.out.print(i + " ");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment