Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading;
- namespace PrimeTriangle
- {
- class Program
- {
- static bool IsPrime(int n)
- {
- if (n > 1)
- {
- return Enumerable.Range(1, n).Where(x => n % x == 0)
- .SequenceEqual(new[] { 1, n });
- }
- return false;
- }
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- int count = 0;
- List<int> primes = new List<int>();
- for (int i = 1; i <= n; i++)
- {
- if (IsPrime(i))
- {
- primes.Add(i);
- }
- }
- Console.WriteLine("1");
- for (int i = 0; i < primes.Count; i++)
- {
- for (int j = 1; j <= primes[i]; j++)
- {
- if (IsPrime(j))
- {
- Console.Write("1");
- }
- else if (j == 1)
- {
- Console.Write("1");
- }
- else
- {
- Console.Write("0");
- }
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement