Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@pawlos
Created August 18, 2018 11:36
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 pawlos/5df9985010dad7c8d4a7fad64bd1fd49 to your computer and use it in GitHub Desktop.
Save pawlos/5df9985010dad7c8d4a7fad64bd1fd49 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp2
{
class Program
{
public static bool IsPrime(int n)
{
if (n < 4)
{
return true;
}
for (int i = 2; i * i <= n; i++)
{
if (n%i==0) return false;
}
return true;
}
static void Main(string[] args)
{
Array.ForEach(Enumerable.Range(2, Int32.MaxValue - 2)
.Where(IsPrime)
.Take(20)
.Select(x => x * x)
.Reverse().ToArray(), Console.WriteLine);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment