(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:
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.
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...')
I'm ready for the competetion
This one is over.
Fell free to start one, I'd like a challenge.