python version #942
iblissstudent
started this conversation in
Ideas
Replies: 2 comments
-
@iblissstudent I'm guessing you're aware that we already have 3 solutions in Python, all of which conform to the rules that apply to Primes solutions. Amongst others, that means that the sieve size is not 100,000 but 1,000,000. Based on that premise, I'm not sure exactly what kind of feedback you're trying to get on this post? |
Beta Was this translation helpful? Give feedback.
0 replies
-
That’s a good start! Now make it faster, then make it faster yet. Keep going until you can’t make it any faster!
… On Oct 7, 2023, at 11:18 AM, iblissstudent ***@***.***> wrote:
i made this in python:
def IsPrime(Number):
if str(Number)[-1] == '5' or str(Number)[-1] == '0' or Number % 2 == 0:
return False
passes = 0
for num in list(range(1, int(str(float(Number)**0.5 + 1).split('.')[0]) + 1)[1:]):
if str(Number / num)[-2:] == '.0':
passes -= 1
else:
pass
if passes == 0:
return Number
else:
return False
for num in range(1, 100001):
if IsPrime(num) != False:
pass
and it calculates all the primes between 1 > 100000 (excluding 2,5) in about 8 seconds
—
Reply to this email directly, view it on GitHub <#942>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AA4HCF3US4BQMB5ZYGYFNDTX6GMHPAVCNFSM6AAAAAA5XCZDEWVHI2DSMVQWIX3LMV43ERDJONRXK43TNFXW4OZVG4YTCMZTHE>.
You are receiving this because you are subscribed to this thread.
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
i made this in python:
output:
and it calculates all the primes between 1 > 100000 (excluding 2) in about 548 milliseconds
Beta Was this translation helpful? Give feedback.
All reactions