internal static string Summation_of_primes() { long sum = 0; var resultList = new List <long>(); for (long i = 2; i <= value; i++) { if (!Primes.HasMultiplier(i, resultList)) { resultList.Add(i); } } foreach (long val in resultList) { sum = sum + val; } return(sum.ToString()); }
internal static List <Int64> GetPrimeListOfDivisors(Int64 value, bool useCache = false) { var originalValue = value; var resultlist = new List <Int64>(); for (long i = 2; i < value; i++) { if (IsDivisor(value, i)) { if (!Primes.HasMultiplier(i, resultlist)) { resultlist.Add(i); value = value / i; if (useCache) { List <Int64> list = null; if (Divisors.PrimeListOfDivisorsCache.TryGetValue(value, out list)) { foreach (var listVal in list) { resultlist.Add(listVal); } PrimeListOfDivisorsCache.Add(originalValue, resultlist); return(resultlist); } } i = 2; } } } if (!Primes.HasMultiplier(value, resultlist)) { resultlist.Add(value); } if (useCache) { PrimeListOfDivisorsCache.Add(originalValue, resultlist); } return(resultlist); }
internal static string st_prime() { var resultList = new List <long>(); int elem = 2; while (resultList.Count < 10001) { if (!Primes.HasMultiplier(elem, resultList)) { resultList.Add(elem); elem += 1; } else { elem += 1; } } var result = resultList[resultList.Count - 1]; return(result.ToString()); }