static void Main(string[] args)
{
List<int> numbers = ShowPrime();
Int32.TryParse(Console.ReadLine(), out int count);
List<string> limits = new List<string>();
//считываем лимиты
for (int i = 0; i < count; i++)
{
limits.Add(Console.ReadLine());
}
for (int i = 0; i < count; i++)
{
var limitgroup = limits[i].Split(' ');
var start = numbers.FindLastIndex(x => x <= Int32.Parse(limitgroup[0]));
var end = numbers.FindLastIndex(x => x <= Int32.Parse(limitgroup[1]));
if (start < 0) start = 0;
for (int j = start; j <= end; j++)
{
Console.WriteLine(numbers[j]);
}
}
}
public static List<int> ShowPrime()
{
List<int> numbers = new List<int>();
bool isPrime;
for (int i = 2; i <= 32000; i++)
{
isPrime = true;
if (i > 10) { if (i % 10 == 5 || i % 2 == 0) continue; } // ускоритель
for (int j = 2; j < (int)(Math.Sqrt(i) + 1); j++)
{
if (j * j - 1 > i) { isPrime = false; break; }
if (i % j == 0 && i > 2) { isPrime = false; break; }
}
if (isPrime) numbers.Add(i);
}
return numbers;
}
I get a wrong answear?but i check in list i have exatly only prime numbers? I dont understand which test is failed
created
last reply
- 5
replies
- 961
views
- 2
users
- 1
like
- 1
link