Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void Main(string[] args)
- {
- Stopwatch sw = Stopwatch.StartNew();
- List<BigInteger> results = new List<BigInteger>();
- object _lock = new object();
- Parallel.For(2,101, i =>
- {
- Parallel.For(2, 101, j =>
- {
- BigInteger powResult = BigInteger.Pow(i, j);
- if (!results.Contains(powResult))
- {
- lock (_lock)
- {
- results.Add(powResult);
- }
- }
- });
- });
- sw.Stop();
- Console.WriteLine(results.Count);
- Console.WriteLine("Time: " + sw.ElapsedMilliseconds + " ms.");
- Console.Read();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement