Created
May 25, 2016 08:04
-
-
Save Nikola-Andreev/a88485cfef4061861fb68aa7950cc72a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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