Forgot your password?
typodupeerror
User Journal

dcowart's Journal: A086865 solution in python

Journal by dcowart

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:

The amount of weight an evangelist carries with the almighty is measured in billigrahams.

Working...