@acwoss/

LightyellowLovableDeclarations

Python

No description

fork
loading
Files
  • main.py

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.4782146073377298","path":"main.py","file":{"path":"main.py","content":{"asEncoding":{"base64":"aW1wb3J0IHRpbWUKIApkZWYgaXNfcHJpbWUobnVtYmVyKToKICAgIGkgPSAzCiAgICB3aGlsZSBpKioyIDw9IG51bWJlcjoKICAgICAgICBpZiBudW1iZXIgJSBpID09IDA6CiAgICAgICAgICAgIHJldHVybiBGYWxzZQogICAgICAgIGkgKz0gMgogICAgcmV0dXJuIFRydWUKIApkZWYgbHVjYXNfbGVobWVyKHApOgogICAgcyA9IDQKICAgIE0gPSAyKipwIC0gMQogCiAgICBmb3IgXyBpbiByYW5nZShwIC0gMik6CiAgICAgICAgcyA9ICgocyAqIHMpIC0gMikgJSBNCiAgICByZXR1cm4gcyA9PSAwCiAKZGVmIG1lcnNlbm5lX3ByaW1lcygpOgogICAgcCA9IDMKICAgIHdoaWxlIFRydWU6CiAgICAgICAgaWYgaXNfcHJpbWUocCkgYW5kIGx1Y2FzX2xlaG1lcihwKToKICAgICAgICAgICAgeWllbGQgKHAsIDIqKnAgLSAxKQogICAgICAgIHAgKz0gMgogCnN0YXJ0ID0gdGltZS50aW1lKCkKbnVtYmVycyA9IG1lcnNlbm5lX3ByaW1lcygpCiAKZm9yIF8gaW4gcmFuZ2UoMTcpOgogICAgcCwgbWVyc2VubmUgPSBuZXh0KG51bWJlcnMpCiAgICBwZXJmZWN0ID0gMioqKHAtMSkgKiBtZXJzZW5uZQogICAgcHJpbnQocGVyZmVjdCkKIApwcmludCgnRXhlY3V0YWRvIGVtICcgKyBzdHIodGltZS50aW1lKCkgLSBzdGFydCkgKyAncycp"},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import time
 
def is_prime(number):
    i = 3
    while i**2 <= number:
        if number % i == 0:
            return False
        i += 2
    return True
 
def lucas_lehmer(p):
    s = 4
    M = 2**p - 1
 
    for _ in range(p - 2):
        s = ((s * s) - 2) % M
    return s == 0
 
def mersenne_primes():
    p = 3
    while True:
        if is_prime(p) and lucas_lehmer(p):
            yield (p, 2**p - 1)
        p += 2
 
start = time.time()
numbers = mersenne_primes()
 
for _ in range(17):
    p, mersenne = next(numbers)
    perfect = 2**(p-1) * mersenne
    print(perfect)
 
print('Executado em ' + str(time.time() - start) + 's')