Problem 47

completed December 17, 2011

Code

def isprime(n):
	if n == 0 or n == 1: return 'false'
	for i in range(2, int(n**.5) + 1):
		if n%i == 0: return 'false'
	return 'true'

primeslist = []

def factorcount(n):
	times = 0
	for p in primeslist:
		if n%p == 0: times += 1
	return times

count = 0
n = 1
while count < 4:
	n += 1
	if isprime(n) == 'true': primeslist.append(n)
	print n, count
	if factorcount(n) == 4:
		count += 1
	else:
		count = 0

print n, 'is the fourth number'