Initial commit

master
Ivan Zahariev 2016-11-03 22:08:09 +02:00
parent 3251c0c432
commit 09356704b2
3 changed files with 6687 additions and 0 deletions

70
dotnet/Program.cs Normal file
View File

@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
namespace ConsoleApplication
{
public class Program
{
private static void get_primes7(int n, List<int> res)
{
if (n < 2) return;
if (n == 2)
{
res.Add(2);
return;
}
List<int> s = new List<int>();
for (int z = 3; z < n + 1; z += 2)
{
s.Add(z);
}
int mroot = (int)Math.Sqrt(n);
int half = s.Count;
int i = 0;
int m = 3;
while (m <= mroot)
{
if (s[i] != 0)
{
int j = (int)((m * m - 3) * 0.5);
s[j] = 0;
while (j < half)
{
s[j] = 0;
j += m;
}
}
i = i + 1;
m = 2 * i + 3;
}
res.Add(2);
s.RemoveAll(item => item == 0);
res.AddRange(s);
}
public static double getPeriodTime()
{
string runTimeS = Environment.GetEnvironmentVariable("RUN_TIME");
if (runTimeS == null || runTimeS.Length == 0)
{
throw new ArgumentException("Environment RUN_TIME is not set");
}
return Convert.ToDouble(runTimeS);
}
public static void Main(string[] args)
{
DateTime startTime = DateTime.Now;
double periodTime = getPeriodTime();
while ((DateTime.Now - startTime).TotalSeconds < periodTime) {
List<int> res = new List<int>();
get_primes7(10000000, res);
Console.Write("Found {0} prime numbers.\n", res.Count);
}
}
}
}

19
dotnet/project.json Normal file
View File

@ -0,0 +1,19 @@
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.1"
}
},
"imports": "dnxcore50"
}
}
}

6598
dotnet/project.lock.json Normal file

File diff suppressed because it is too large Load Diff