Advertisement
Guest User

Untitled

a guest
Oct 10th, 2017
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. class Program
  8. {
  9. static void Main()
  10. {
  11. int e = int.Parse(Console.ReadLine());
  12. int number = int.Parse(Console.ReadLine());
  13. var primes = new List<int>();
  14.  
  15. {
  16. for (int i = e; i <= number; i++)
  17. {
  18. if (i == 0 || i == 1)
  19. {
  20. i = 2;
  21. }
  22.  
  23. bool isPrime = true;
  24. for (int j = 2; j <= Math.Sqrt(i); j++)
  25. {
  26. if (i % j == 0)
  27. {
  28. isPrime = false;
  29. break;
  30. }
  31. }
  32. if (isPrime)
  33. {
  34.  
  35. primes.Add(i);
  36. }
  37.  
  38. }
  39. }
  40. Console.WriteLine(string.Join(", ",primes));
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement