Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python competiton
#21
(10-09-2009, 01:19 PM)Fallen Wrote: And yes I'm aware that was only an "isprime" function, just trying to help some others out lol

Yes I know but some guy thought you won (I bet u could), I just cleared the things out.
I think you guys have problem with testing if a give number is dividable by your current prime.

One of the solutions is very simple but kinda tricky.

A little tip:

Code:
>>> 15/4
3
Reply
#22
Here are my scripts:
They are in .exe, but i will post the source when competition ends.

Download link

It's an archive with my .exe files and files that are necessary to run them. Put it in a folder and extract.
Reply
#23
wat it's abt
[Image: 2d75599e9a.png]:superman:
Reply
#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
#25
I'm ready for the competetion
[Image: 2d75599e9a.png]:superman:
Reply
#26
This one is over.
Fell free to start one, I'd like a challenge.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python Help Dεlluzion 3 2,043 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: 16 Guest(s)