Witam mam problem z dalszym pisaniem programu, który za zadanie ma zaproponowanie bardziej efektywnego algorytmu przy zachowaniu niezmienionego interfejsu podprogramu. Przeprowadzić analizę za pomocą instrumentacji i pomiarów czasu. Przyjąć, że operacją dominującą jest dzielenie modulo (%)
Badanie przeprowadzić dla następującego zbioru punktów pomiarowych (liczb pierwszych): { 100913, 1009139, 10091401, 100914061, 1009140611, 10091406133, 100914061337, 1009140613399 }
using System;
using System.Numerics;
namespace LiczbyPierwsze
{
class Program
{
static ulong DivsNum;
static bool AlgorytmPrzykładowy(BigInteger Num)
{
if (Num < 2) return false;
else if (Num < 4) return true;
else if (Num % 2 == 0) return false;
else for (BigInteger u = 3; u < Num / 2; u += 2)
if (Num % u == 0) return false;
return true;
}
static bool AlgorytmPrzykładowyInstrumentacja(BigInteger Num)
{ ...
}
static bool AlgorytmLepszy(BigInteger Num)
{ ...
}
static bool AlgorytmLepszyInstrumentacja(BigInteger Num)
{ ...
}
static bool AlgorytmJeszczeLepszy(BigInteger Num)
{ ...
}
static bool AlgorytmJeszczeLepszyInstrumentacja(BigInteger Num)
{ ...
}
static void Main(string[] args)
{
BigInteger[] PrimeNums = new BigInteger[]{ 101, 1009, 10091, 100913, 1009139, 10091401, 100914061,
1009140611, 10091406133, 100914061337, 1009140613399 };
// testy
}
}
}