Created
August 18, 2018 11:36
-
-
Save pawlos/5df9985010dad7c8d4a7fad64bd1fd49 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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