コード例 #1
0
def SmallestNumber(n):
  from Euler_Prime import IsPrime
  #from math import sort
  smallestnum = 1

  factlist = [1]

  # first gather all primes <= n

  for i in range(1,n+1):
    if IsPrime(i):
       factlist.append(i)
       zz = i
       smallestnum *= zz
    else:
       temp = float(smallestnum)/float(i)
       if temp != int(temp):
         print "oops",i, smallestnum, temp
         y = (temp - int(temp))          
         zz = int(round(1.0/y,2))
         print "zz",zz,y
         factlist.append(zz)
         smallestnum *= zz
  if zz != n:factlist.append(n)
  #factlist.sort()
  print "Smallest Number that can be divided by Range(1,",n,") is", smallestnum
  print ""
  #print factlist
  factlist.sort()
  print factlist
コード例 #2
0
from Euler_Prime import IsPrime

num = 0

for i in range(2, 1000000):  ##0000

    if IsPrime(i):

        xx = str(i)
        xlen = len(xx)
        iscirc = True
        for j in range(1, xlen + 1):
            xx = xx[1:] + xx[:1]
            if IsPrime(int(xx)) == False:
                iscirc = False
        if iscirc:
            num += 1

print "# of Circular Primes is ", num
コード例 #3
0
from Euler_Prime import IsPrime

lim = 1000

for i in range(1, lim):

    if IsPrime(i):
        print i, i % 6
コード例 #4
0
ファイル: Part1.py プロジェクト: MikeOcc/MyProjectEulerFiles
yp = 0
zp = 0
wp = 0

MaxPrime = 200
StartPrime = 100

howdeep = 25

print "Beginning sum of Primes=q such that P(q) =", MaxPrime

print type(flsort)

for s in range(StartPrime, MaxPrime):

    if IsPrime(s):
        sumtofind = s
        print "for prime = ", s
    else:
        sumtofind = 0
        continue
    prevd = 0
    howdeep = 0
    for d in flsort:
        howdeep = howdeep + 1
        howdeep2 = d
        #print howdeep2
        if howdeep2 > s:
            #howdeep = prevd
            break
        #else:
コード例 #5
0
ctr = 7
numprimes = 0
prevmaxsum = 0
prevprime = 0
curprime = 0
primestring = ""

while maxsum < 1000000:

   #print #  "test number is ", ctr

   prevmaxsum = maxsum
   prevprime = curprime
   xx = "Current Sum isn't Prime"

   if IsPrime(ctr):
      curprime = ctr
      primestring = primestring + str(curprime) + ","
      maxsum+=curprime      
      numprimes+=1
      if IsPrime(maxsum): xx ="Current Sum is Prime"
      
   if maxsum >999999:
      break
   elif IsPrime(ctr):
      print "\n", numprimes, " Prime is ", ctr, "Sum is ", maxsum, ctr%6, xx

   
   ctr = ctr + 1