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)
- {
- // User input
- int firstStart = int.Parse(Console.ReadLine());
- int secondStart = int.Parse(Console.ReadLine());
- int diff1 = int.Parse(Console.ReadLine());
- int diff2 = int.Parse(Console.ReadLine());
- // Calculate threshold
- int firstEnd = firstStart + diff1;
- int secondEnd = secondStart + diff2;
- for ( int i = firstStart; i <= firstEnd; i++ )
- {
- for ( int j = secondStart; j <= secondEnd; j++ )
- {
- // Assume number is prime by default
- bool isPrime = true;
- // Check if prime
- for ( int k = 2; k < 10; k++ )
- {
- if ( i%k == 0 || j%k == 0 )
- {
- // If number can be divided by 2, 3, ..., 9 - not prime
- isPrime = false;
- }
- }
- // Print only prime numbers
- if ( isPrime )
- {
- Console.WriteLine("{0}{1}", i, j);
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement