# Euler 027
# Quadratic Primes
#
# pqc.py
# Prime Quadratic Count
# This program was a helper for the problem: it found the number of primes
# generated by a series of quadratics.
#
# General equation of Quadratic:
# y = (x - k/2)^2 + v (- 0.25)
# For this preliminary test, k = -1
#
# I also know that v MUST end in 1 or 7.

from math import ceil, sqrt
import signal

def isPrime(n):
	if n < 2: return False
	if n == 2 or n == 3: return True
	if n % 2 == 0 or n % 3 == 0: return False
	
	max = ceil(sqrt(n)) + 1
	i = 6
	while i <= max:
		if n % (i - 1) == 0 or n % (i + 1) == 0: return False
		i += 6
		
	return True
# end isPrime


def status(s, f):
	print("\tCurrently on", v)
# Get status with control-T (mac only)
signal.signal(signal.SIGINFO, status)

v = 7
k = -1

while v < 1000:
	if v % 10 == 1:
		v += 6 # make it the next 7
	elif v % 10 == 7:
		v += 4 # make it the next 1

	x = 0
	quadDone = False
	while not quadDone:
		y = int((x - float(k)/2) ** 2 + v - 0.25)
		#print(x, "-->", y)
		if not isPrime(y):
			quadDone = True
		
		x += 1
			
			
	if x > 5: print(k, v, "generates\t", x, "primes")
		

	
	
