using System; using System.Numerics; using System.Diagnostics; namespace ProjektAlgorytmy2 { class Program { static void Main(string[] args) { BigInteger[] tablica = new BigInteger[] { 100913, 1009139, 10091401, 100914061, 1009140611, 10091406133, 100914061337, 1009140613399 }; //tablica z wyrazami Stopwatch Stoper = new Stopwatch(); for( int i = 0 ; i < tablica.Length ; i++ ) //pętla wykonująca funkcję IsPrime dla wszystkich wyrazów tablicy ,,tablica" { long counter; Stoper.Start(); IsPrime2(tablica[i] , out counter); Stoper.Stop(); Console.WriteLine("Czas: "+Stoper.Elapsed); Console.WriteLine("Ilość operacji: "+counter); Stoper.Reset(); } } static bool IsPrime2( BigInteger Num , out long operacja ) //funkcja przyzwoita { operacja = 1; if (Num < 2) return false; else if (Num < 4) return true; else if (Num % 2 == 0) return false; else { for (BigInteger u = 3; u*u <= Num; u += 2) { operacja++; if (Num % u == 0) return false; } } return true; } } }