Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let n = +gets();
- let arrPrime = [];
- for (let i = n; i > 1; i--) {
- for (let j = 2; j < i; j++) {
- if (i % j == 0) {
- break;
- }
- if (j == i - 1) {
- arrPrime.unshift(i);
- }
- }
- }
- arrPrime.unshift(1, 2);
- let count = arrPrime.length;
- for (let i = 0; i < count; i++) {
- num = arrPrime[i];
- let colum = '';
- for (let j = 1; j <= num; j++) {
- if (j == 1 || j == 2 || j == 3 || j == num) {
- colum += 1;
- } else {
- for (let k = 2; k <= j; k++) {
- if (j % k == 0 && j != k) {
- colum += 0;
- break;
- } else if (k == j) {
- colum += 1;
- }
- }
- }
- }
- print(colum);
- }
Advertisement
Add Comment
Please, Sign In to add comment