Advertisement
Guest User

Untitled

a guest
Apr 8th, 2018
852
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 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. namespace _06._2PrimePairs
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int firsDoubleStart = int.Parse(Console.ReadLine());
  14. int secondDoubleStart = int.Parse(Console.ReadLine());
  15. int firsDoubleLenght = int.Parse(Console.ReadLine());
  16. int secondDoubleLenght = int.Parse(Console.ReadLine());
  17.  
  18. // check input data
  19.  
  20. if (firsDoubleStart >= 10 && firsDoubleStart <= 90 && secondDoubleStart >= 10 && secondDoubleStart <= 90 && firsDoubleLenght >= 1 && firsDoubleLenght <= 9 && secondDoubleLenght >= 1 && secondDoubleLenght <= 9)
  21. {
  22.  
  23. for (int first = firsDoubleStart; first <= firsDoubleStart + firsDoubleLenght; first++)
  24. {
  25. for (int second = secondDoubleStart; second <= secondDoubleStart + secondDoubleLenght; second++)
  26. {
  27. // check for prime
  28.  
  29. bool firstCheck = true;
  30. for (int n = 2; n <= Math.Floor(Math.Sqrt(first)); n++)
  31. {
  32. if (first % n == 0)
  33. {
  34. firstCheck = false;
  35. }
  36. }
  37.  
  38. bool secondCheck = true;
  39. for (int m = 2; m <= Math.Floor(Math.Sqrt(second)); m++)
  40. {
  41. if (second % m == 0)
  42. {
  43. secondCheck = false;
  44. }
  45. }
  46.  
  47. if (firstCheck && secondCheck)
  48. {
  49. Console.WriteLine("{0}{1}", first, second);
  50. }
  51.  
  52.  
  53. }
  54. }
  55.  
  56. }
  57. }
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement