Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- public class PrimesInGivenRange
- {
- public static void Main()
- {
- Console.WriteLine(String.Join(", ", GetNumbers()));
- }
- public static int[] GetNumbers()
- {
- int start = int.Parse(Console.ReadLine());
- int end = int.Parse(Console.ReadLine());
- List<int> list = new List<int>();
- for (int i = start; i <= end; i++)
- {
- int isPrime = 0;
- for (int j = 1; j < i; j++)
- {
- if (i % j == 0)
- {
- isPrime++;
- }
- if (isPrime == 2)
- {
- break;
- }
- }
- if (isPrime != 2)
- list.Add(i);
- }
- return list.ToArray();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement