Пример #1
0
counter = 0
circulars = 0

def hasEvenDigits(n):
    strNum = str(n)
    if '0' in strNum or '2' in strNum or '4' in strNum or '6' in strNum or '8' in strNum:
        return True
    else:
        return False
 
#populate primeList
primeList = atkins(maximi)

while maximi > 1:
    if maximi == 2 or not hasEvenDigits(maximi):
        if search(maximi,primeList):
            iterator = 0
            tested = maximi
            while iterator < len(str(maximi)):
                origStr = list(str(tested))
                newStr = list(str(tested))
                while len(origStr) < len(str(maximi)):
                    origStr.insert(0, "0")
                    newStr.insert(0, "0")
                counter = 0
                while counter < len(str(maximi)):
                    newStr[counter-1] = origStr[counter]
                    counter += 1
                tested = int("".join(newStr))
                if search(tested,primeList):
                    if iterator == len(str(maximi))-1:
Пример #2
0
#!/usr/bin/python
# Filename: Problem0012.py, projecteuler.net
# What is the value of the first triangle number to have over five hundred divisors?
from listWorm import search

def triangleNum(n):
    return (n**2 + n)/2

def pentagonNum(n):
    return (3*n**2 - n)/2

def hexagonNum(n):
    return (2*n**2 - n)
     	        
integer = [165, 143, 285]
triList = []
hexList = []
penList = []

for i in range(1,56000):
    triList.append(triangleNum(i))
    hexList.append(hexagonNum(i))
    penList.append(pentagonNum(i))

for i in triList:
    if search(i,hexList):
        if search(i,penList):
            print 'Found num that is tri, hex and pen number: {0}'.format(i)    
Пример #3
0
from atkins import atkins
from listWorm import search
from random import *

maximi = 1000000
primeList = atkins(maximi)
#print(len(primeList))
i=0
while i < 1000:
    # Jos LSB bit eri kuin 1 niin luku ei voi olla prime.
    if not i & 1:
        i += 1
        continue
    # Luvulla mahdollisuus olla prime.
    search(randint(0,1000000-1), primeList)
    i += 1