Follow Slashdot blog updates by subscribing to our blog RSS feed

 



Forgot your password?
typodupeerror
×
User Journal

Journal dcowart's Journal: A086865 solution in python

OEIS A086865 in python

import math

def isprime(possprime):
        """returns t/f if number is prime or not"""
        for x in range(2, int(possprime/2)+1):
                if possprime % x == 0:
                        return False
        else:
                return True

n = 0

while n < 10:
        pp = 2 * math.pow(10,n) + 11
        print "Working on ", n
        if isprime(pp):
                print n, " gives ", pp, " which is prime."
        n=n+1

Works for python up to n = 8. Then runs out of memory :-( Just means I have to rewrite it in C.

This discussion has been archived. No new comments can be posted.

A086865 solution in python

Comments Filter:

FORTRAN is not a flower but a weed -- it is hardy, occasionally blooms, and grows in every computer. -- A.J. Perlis

Working...