Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace PrimeTriangle
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- int counter = 0;
- int counterPrimeNumbers = 0;
- List<int> primeNumbers = new List<int>();
- for (int i = 1; i <= n; i++)
- {
- for (int j = 1; j <= i; j++)
- {
- if (i % j == 0)
- {
- counter++;
- }
- else
- {
- continue;
- }
- }
- if (counter == 2 || i == 1)
- {
- counterPrimeNumbers++;
- primeNumbers.Add(i);
- for (int j = 1; j <= i; j++)
- {
- if (primeNumbers.Contains(j))
- {
- Console.Write(1);
- }
- else
- {
- Console.Write(0);
- }
- }
- Console.WriteLine();
- }
- counter = 0;
- }
- for (int i = 0; i < primeNumbers.Count; i++)
- {
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment