def isPrime(n): for x in range(2,int(n/2)+1): if n%x == 0: return False return True def fourPrimeFactors(n): multiples = [] for x in range(2,int(n/2)+1): if n%x == 0: multiples.append(x) if(len(multiples)<4): return False primecount,counter = 0,0 while counter < len(multiples): if primecount >=4: return True if isPrime(multiples[counter]): primecount+=1 counter+=1 return False for x in range(3,1000000): if fourPrimeFactors(x) == True and fourPrimeFactors(x-1) == True and fourPrimeFactors(x-2) == True and fourPrimeFactors(x-3) == True: print(x-3) break