def test(a,b,c): bToReturn = True if not pfp.is_prime(a): bToReturn = False if bToReturn and not pfp.is_prime(b): bToReturn = False if bToReturn and not pfp.is_prime(c): bToReturn = False if bToReturn and c-b != b-a: bToReturn = False comp_digits(a,b,c)
def check_truncation(nNum): anDigits = [] anToCheck = [] nExponent = 0 nGrowing = 0 while nNum > 0: anToCheck.append(nNum) nGrowing = nGrowing + (nNum %10)*(10**nExponent) anToCheck.append(nGrowing) #anToCheck.append( sum( map( lambda(x): anDigits.append( nNum%10 )))) nNum/=10 nExponent += 1 bToReturn = True for nToCheck in anToCheck: if not pfp.is_prime(nToCheck) or nToCheck == 1: bToReturn = False return bToReturn
def next_odd_composite(nOn): nOn += 2 while pfp.is_prime(nOn): nOn +=2 return nOn
import pfp import enum_pan_digital #using array of digits over number for ease of setting up next anDigits = [9,8,7,6,5,4,3,2,1] #digits from least significant to most. nCount =0 #debugging number of times through loop checking that next works nLen = 9 while True: #smallest possible ... nToCheck = sum(map(lambda (nIndex, nElement): nElement*(10**(len(anDigits) - 1 - nIndex)), enumerate(anDigits))) #if len(anDigits) != nLen: # print(nToCheck) if nToCheck == 2143: print('should be prime') if pfp.is_prime(nToCheck): print(nToCheck) break else: #print(anDigits) anDigits = enum_pan_digital.enum_pan_digital(anDigits) #print(anDigits) #if nCount > 500000: # break #nCount += 1