0% found this document useful (0 votes)
5 views1 page

Using System - Collections.concurrent

The document contains a C# program that calculates a specific set of integers based on factorial computations and parallel processing. It uses a ConcurrentBag to store results and checks if the sum of the integer, its factorials modulo 5 and 7, is divisible by 96800. Finally, it outputs the sorted list of valid integers to the console.

Uploaded by

Mr Nake
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

Using System - Collections.concurrent

The document contains a C# program that calculates a specific set of integers based on factorial computations and parallel processing. It uses a ConcurrentBag to store results and checks if the sum of the integer, its factorials modulo 5 and 7, is divisible by 96800. Finally, it outputs the sorted list of valid integers to the console.

Uploaded by

Mr Nake
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

using System.Collections.

Concurrent;

namespace Zad_dom_program_równoległę
{
internal class Program
{
static void Main(string[] args)
{
ConcurrentBag<int> tmp = new ConcurrentBag<int>();
Parallel.For(1, 1000001, i =>
{
int silnia1 = 1;
int silnia2 = 1;
for (int x = 1; x < (i % 5 + 1); x++)
{
silnia1 = silnia1 * x;
}
for (int x = 1; x < (i % 7 + 1); x++)
{
silnia2 = silnia2 * x;
}
if ((i + silnia1 + silnia2) % 96800 == 0)
{
tmp.Add(i);
}
});
List<int> solution = tmp.ToArray().OrderBy(i => i).ToList();

for (int i = 0; i < solution.Count; i++)


{
Console.WriteLine(solution[i]);
}
}
}
}

You might also like