public void CalculatePrimes(long limit)
 {
     for (long i = 1; i < limit; i++)
     {
         bool isPrime = true;
         for (long j = 2; j < i; j++)
         {
             if (i % j == 0)
             {
                 isPrime = false;
                 break;
             }
         }
         
         if (isPrime)
         {
             PrimeEventArgs args = new PrimeEventArgs(i);
             this.PrimeFound?.Invoke(this, args);
         }
     }
 }
Ejemplo n.º 2
0
 public void Action(object sender, PrimeEventArgs args)
 {
     Console.WriteLine($"A prime number hass been found, it is: {args.Prime}");
 }