Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace PrimePairs
- {
- class Program
- {
- static void Main(string[] args)
- {
- int firstNum = int.Parse(Console.ReadLine());
- int secondNum = int.Parse(Console.ReadLine());
- int firstDiff = int.Parse(Console.ReadLine());
- int secondDiff = int.Parse(Console.ReadLine());
- for (int i = firstNum; i <= firstNum + firstDiff; i++)
- {
- for (int j = secondNum; j <= secondNum + secondDiff; j++)
- {
- bool isFirstPrime = true;
- bool isSecondPrime = true;
- for (int k = 2; k <= Math.Sqrt(i); k++)
- {
- if (i % k == 0)
- {
- isFirstPrime = false;
- break;
- }
- }
- for (int k = 2; k <= Math.Sqrt(j); k++)
- {
- if (j % k == 0)
- {
- isSecondPrime = false;
- break;
- }
- }
- if (isFirstPrime && isSecondPrime)
- {
- Console.WriteLine($"{i}{j}");
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement