Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class PrimeTriangle {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int n = Integer.parseInt(scan.nextLine());
- String output = "";
- for (int i = 1; i <= n; i++) {
- boolean isPrime = true;
- for (int j = 2; j <= i - 1 ; j++) {
- if (i % j == 0){
- isPrime = false;
- break;
- }
- }
- if (isPrime) {
- output += "1";
- System.out.println(output);
- } else {
- output += "0";
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement