public long GetFirstConsecutivenumberWith(int primefactors, int numberConsecutive) { primes = Primes.GetPrimeFactorsBelowNumber(200000).ToArray(); long number = 1; while (true) { long distinctprimeFactorsInNumber = 0; for (int j = 0; j < numberConsecutive; j++) { distinctprimeFactorsInNumber = GetDistinctprimeFactorsInNumber(number + j, primefactors); if (distinctprimeFactorsInNumber != primefactors) { number += j; break; } } if (distinctprimeFactorsInNumber == primefactors) { return(number); } number++; } }
public E070TotientPermutation(int size) { primeFactors = Primes.GetPrimeFactorsBelowNumber((long)size); primeDict = primeFactors.ToDictionary(e => e); vSize = size; totient = new Totient(size); }
public E077PrimeSummations(int size) { this.Size = size; primliste = Primes.GetPrimeFactorsBelowNumber(size); dictionary = primliste.ToDictionary(e => e); primliste.Reverse(); }
public long GetSmallestReplacementPrimesWith(int startnumber, int maxNumber, int primevalfamily) { PrimeDictionary = Primes.GetPrimeFactorsBelowNumber(maxNumber).ToDictionary(e => e); minPrime = startnumber; while (startnumber < maxNumber) { var str = startnumber.ToString(); int max = 1 << str.Length; for (int hidingNumber = 1; hidingNumber < max; hidingNumber++) { var str2 = Star.Hide(str, hidingNumber); long[] re = GetReplacementPrimes(str2); if (re.Length == primevalfamily) { return(re[0]); } } startnumber++; while (startnumber % 2 == 0 || startnumber % 3 == 0) { startnumber++; } } return(-1); }
public E050ConsecutivePrimeSum(int below) { var l = Primes.GetPrimeFactorsBelowNumber(below); ConsecutivePrimeFactors = l.ToArray(); PrimeFactorHash = l.ToDictionary(e => e); MaxPrimeFactorIndex = ConsecutivePrimeFactors.Length - 1; MaxPrimeFactor = ConsecutivePrimeFactors[MaxPrimeFactorIndex]; }
public E357PrimeGeneratingIntegers(int Max) { this.Max = Max; primeliste = Primes.GetPrimeFactorsBelowNumber((long)Math.Sqrt(Max)); /// primeDictionary = Primes.GetPrimeFactorsBelowNumber((long)Math.Sqrt(Max)).ToDictionary(e=>e); // primeliste = Primes.GetPrimeFactorsBelowNumber(Max+1); primeDictionary = primeliste.ToDictionary(e => e); primeDictionary.Add(1, 1); }
public long SumOfStrongRightTruncatableHarshadPrimes(long max) { long sum = 0; prinmeListe = Primes.GetPrimeFactorsBelowNumber((long)Math.Sqrt(902200000800800)); var file = File.CreateText(@"c:\temp\HarshadNumbers.txt"); List <long> rightTruncatableHarshadNumbers = new List <long>(); //finn rightTruncatableHarshadNumber melloem 10 og 100 for (int n = 10; n < 100; n++) { if (IsRightTruncatableHarshadNumber(n)) { rightTruncatableHarshadNumbers.Add(n); } } for (int p = 1; p < max - 1; p++) { List <long> nextRightTruncatableHarshadNumbers = new List <long>(); // 'left'-expand de kjente TruncatableHarshad nummerne foreach (var n in rightTruncatableHarshadNumbers) { for (int i = 0; i < 10; i++) { //left... long t = n * 10 + i; if (IsStrongHarshadNumber(n) && Primes.IsPrime(t, prinmeListe)) { sum += t; file.WriteLine(t.ToString()); } //til neste 'runde' if (IsRightTruncatableHarshadNumber(t)) { nextRightTruncatableHarshadNumbers.Add(t); } } } rightTruncatableHarshadNumbers = nextRightTruncatableHarshadNumbers; } file.Close(); return(sum); }
public bool IsStrongRightTruncatableHarshadPrimes(long number) { prinmeListe = Primes.GetPrimeFactorsBelowNumber((long)number); long rest = number / 10; if (IsRightTruncatableHarshadNumber(rest) && IsStrongHarshadNumber(rest) && Primes.IsPrime(number, prinmeListe) ) { return(true); } else { return(false); } }
public long GetSum(long below) { return(Primes.GetPrimeFactorsBelowNumber(below).Sum()); }
public E035Circularprimes(int max) { List <long> liste = Primes.GetPrimeFactorsBelowNumber(max); primemap = liste.ToDictionary(e => e); }
public E075SingularIntegerRightTriangles(int size) { primeFactors = Primes.GetPrimeFactorsBelowNumber((long)size); primeDict = primeFactors.ToDictionary(e => e); }
public E060PrimePairSets(int primelistemax) { primliste = Primes.GetPrimeFactorsBelowNumber(primelistemax); }
public E037Truncatableprimes(int max) { primemap = Primes.GetPrimeFactorsBelowNumber(max).ToDictionary(e => e); }
public E058SpiralPrimes(int primelistemax) { primliste = Primes.GetPrimeFactorsBelowNumber(primelistemax); }
public E049PrimePermutations() { PrimeFactors = Primes.GetPrimeFactorsBelowNumber(10000).Where(e => e >= 1000).ToArray <long>();; }