Skip to content

Instantly share code, notes, and snippets.

@Nikola-Andreev
Created May 25, 2016 08:04
Show Gist options
  • Save Nikola-Andreev/a88485cfef4061861fb68aa7950cc72a to your computer and use it in GitHub Desktop.
Save Nikola-Andreev/a88485cfef4061861fb68aa7950cc72a to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;
using System.Globalization;
using System.Text.RegularExpressions;
namespace Praktice
{
class Program
{
static void Main(string[] args)
{
int a = int.Parse(Console.ReadLine());
int b = int.Parse(Console.ReadLine());
List<int> primes = IsPrime(a, b);
PrintPrimes(primes);
}
private static void PrintPrimes(List<int> primes)
{
Console.WriteLine(string.Join(", ",primes));
}
private static List<int> IsPrime(int a, int b)
{
List<int> result = new List<int>();
int count = 0;
int d = Math.Max(a, 2);
for (int i = d; i <= b; i++)
{
for (int c = 2; c < i; c++)
{
if (i % c == 0)
{
count++;
}
}
if (count == 0)
{
result.Add(i);
}
count = 0;
}
return result;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment