using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace PrimeQuadrupleImplementation
{
class Program
{
static int original;
static void Main(string[] args)
{
Console.Title = "Prime Quadruple Implementation";
int n = 0;
A: Console.WriteLine("Please enter number from 13 to 10000000 only.");
n = Convert.ToInt32(Console.ReadLine());
original = n;
if (n < 13 || n > 10000000)
{
goto A;
} else
{
GenerateCount(n);
}
Console.ReadLine();
}
private static void GenerateCount(int n)
{
int a, b, c, d, counter = 0;
a = n;
b = n + 2;
c = n + 6;
d = n + 8;
counter = Is_Prime(a) + Is_Prime(b) + Is_Prime(c) + Is_Prime(d);
Primequadruple(counter, d, n);
}
private static void Primequadruple(int count, int Size, int n)
{
if (count != 4)
{
n = n - 1;
GenerateCount(n);
} else if (Size > original)
{
n--;
GenerateCount(n);
} else
{
Console.WriteLine("Output : {0}", Size.ToString());
}
}
private static int Is_Prime(int Num)
{
int i;
for (i = 2; i <= Num - 1; i++)
{
if (Num % i == 0)
{
return 0;
}
}
if (i == Num)
{
return 1;
}
return 0;
}
}
}You can use this C# code snippet to get the Highest number which follows the Prime quadruple. Like Prime Quadruple is 2,3,5,7 or 11,13,17,19. I have started with 13 to 10000000 but you can change it as per your need.
