Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _06._2PrimePairs
- {
- class Program
- {
- static void Main(string[] args)
- {
- int firsDoubleStart = int.Parse(Console.ReadLine());
- int secondDoubleStart = int.Parse(Console.ReadLine());
- int firsDoubleLenght = int.Parse(Console.ReadLine());
- int secondDoubleLenght = int.Parse(Console.ReadLine());
- // check input data
- if (firsDoubleStart >= 10 && firsDoubleStart <= 90 && secondDoubleStart >= 10 && secondDoubleStart <= 90 && firsDoubleLenght >= 1 && firsDoubleLenght <= 9 && secondDoubleLenght >= 1 && secondDoubleLenght <= 9)
- {
- for (int first = firsDoubleStart; first <= firsDoubleStart + firsDoubleLenght; first++)
- {
- for (int second = secondDoubleStart; second <= secondDoubleStart + secondDoubleLenght; second++)
- {
- // check for prime
- bool firstCheck = true;
- for (int n = 2; n <= Math.Floor(Math.Sqrt(first)); n++)
- {
- if (first % n == 0)
- {
- firstCheck = false;
- }
- }
- bool secondCheck = true;
- for (int m = 2; m <= Math.Floor(Math.Sqrt(second)); m++)
- {
- if (second % m == 0)
- {
- secondCheck = false;
- }
- }
- if (firstCheck && secondCheck)
- {
- Console.WriteLine("{0}{1}", first, second);
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement