Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python competiton
#24
I think there's no one still working on that I'll just post my scripts.

Code:
print "Me haz your primes\nCoded by L0iz\n"
x = int(raw_input("x*y: "))
def is_prime(n):
    import math
    n = abs(n)
    i = 2
    while i <= math.sqrt(n):
        if n % i == 0:
            return False
        i += 1
    return True
z = 2
b = 2
while z*b != x:
    z = z + 1
    if is_prime(z):
        b = x/z
    else:
        pass
print '\nYour primes are', z ,'and', b
l = raw_input('Press enter to quit... ')

Array version

Code:
print "Me haz your primes - Array version\nCoded by L0iz\n "
x = int(raw_input("x*y: "))
array = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31]
l = 1
#######is_prime#######
def is_prime(n):
    import math
    n = abs(n)
    i = 2
    while i <= math.sqrt(n):
        if n % i == 0:
            return False
        i += 1
    return True
#######Array##########
y = 10
def primes(y, z):
    m = 0
    while m < y:
        if is_prime(z):
            m += 1
            array.append(z)
            z += 1
        else:
            z += 1
####Testing primes##        
a = 0
b = 2
while array[a]*b != x:
    if a+1 == y:
        c = array[9]+1
        array = [ ]
        a = 0
        l += 1
        primes(y, c)
    else:
        a += 1
        b = x/array[a]
print '\nYour primes are', b , 'and' , array[a]
print 'Total number of primes generated:', l*10
d = raw_input('Press enter to quit...')
Reply


Messages In This Thread
Python competiton - by L0iz - 10-05-2009, 11:49 AM
RE: Python competiton - by Socrates - 10-08-2009, 04:52 PM
RE: Python competiton - by theEND - 10-08-2009, 05:21 PM
RE: Python competiton - by Socrates - 10-08-2009, 08:04 PM
RE: Python competiton - by Fallen - 10-09-2009, 03:49 AM
RE: Python competiton - by Etheryte - 10-09-2009, 04:31 AM
RE: Python competiton - by Socrates - 10-09-2009, 05:43 AM
RE: Python competiton - by L0iz - 10-09-2009, 05:48 AM
RE: Python competiton - by Etheryte - 10-09-2009, 06:21 AM
RE: Python competiton - by Headshot - 10-09-2009, 06:34 AM
RE: Python competiton - by L0iz - 10-09-2009, 06:41 AM
RE: Python competiton - by Headshot - 10-09-2009, 06:56 AM
RE: Python competiton - by L0iz - 10-09-2009, 07:05 AM
RE: Python competiton - by Etheryte - 10-09-2009, 07:03 AM
RE: Python competiton - by Etheryte - 10-09-2009, 07:09 AM
RE: Python competiton - by L0iz - 10-09-2009, 07:28 AM
RE: Python competiton - by Etheryte - 10-09-2009, 08:49 AM
RE: Python competiton - by L0iz - 10-09-2009, 10:04 AM
RE: Python competiton - by Etheryte - 10-09-2009, 12:02 PM
RE: Python competiton - by Fallen - 10-09-2009, 01:19 PM
RE: Python competiton - by L0iz - 10-10-2009, 12:29 AM
RE: Python competiton - by L0iz - 10-10-2009, 05:39 AM
RE: Python competiton - by Akshay* - 10-10-2009, 05:43 AM
RE: Python competiton - by L0iz - 10-12-2009, 06:17 AM
RE: Python competiton - by Akshay* - 10-12-2009, 06:37 AM
RE: Python competiton - by L0iz - 10-12-2009, 07:12 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python Help Dεlluzion 3 2,036 09-30-2019, 12:59 AM
Last Post: samsmith001
  Simple Python Python Compiler Canoris 21 9,349 06-01-2011, 06:30 PM
Last Post: Filefinder
  Python 2 vs 3? Jake 8 2,720 12-11-2010, 04:13 PM
Last Post: Bursihido
  Python help Kharnage 2 925 02-12-2010, 09:07 PM
Last Post: Kharnage
  "==" and "is" in Python Canoris 1 858 02-07-2010, 03:55 PM
Last Post: uber1337

Forum Jump:


Users browsing this thread: 11 Guest(s)