Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
public static List<int> PrimeFactors(int number)
{
var primes = new List<int>();
for (int div = 2; div <= number; div++)
{
while (number % div == 0)
{
primes.Add(div);
number = number / div;
}
}
return primes;
}
static void Main(string[] args)
{
int[] n = { 12757923, 12878611, 12757923, 15808973, 15780709, 197622519 };
// Calculate each of those numbers' prime factors, in parallel
var factors = n.AsParallel().Select(PrimeFactors).ToList();
// Make a new list showing the smallest factor for each
var smallestFactors = factors.Select(thisNumbersFactors => thisNumbersFactors.Min()).ToList();
// Find the index that corresponds with the largest of those factors
int biggestFactor = smallestFactors.Max();
int whatIndexIsThat = smallestFactors.IndexOf(biggestFactor);
Console.WriteLine("{0} has the largest minimum prime factor: {1}", n[whatIndexIsThat], biggestFactor);
Console.WriteLine(string.Join(" ", factors[whatIndexIsThat]));
}
}

View file

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
private static void Main(string[] args)
{
int j = 0, m = 0;
decimal[] n = {12757923, 12878611, 12757923, 15808973, 15780709, 197622519};
var l = new List<int>[n.Length];
Parallel.For(0, n.Length, i => { l[i] = getPrimes(n[i]); });
for (int i = 0; i<n.Length; i++)
if (l[i].Min()>m)
{
m = l[i].Min();
j = i;
}
Console.WriteLine("Number {0} has largest minimal factor:", n[j]);
foreach (int list in l[j])
Console.Write(" "+list);
}