@anonymous/

FatKaleidoscopicGrayreefshark

Python 2.7

No description

fork
loading
Files
  • main.py

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.5560658974588997","path":"main.py","file":{"path":"main.py","content":{"asEncoding":{"base64":"ZGVmIGlzX3ByaW1lKHgsIHByaW1lcyk6DQogICAgZm9yIHAgaW4gcHJpbWVzOg0KICAgICAgICBpZiB4ICUgcCA9PSAwOg0KICAgICAgICAgICAgcmV0dXJuIEZhbHNlDQogICAgcmV0dXJuIFRydWUNCg0KYXNzZXJ0IGlzX3ByaW1lKDMsIFsyXSkNCmFzc2VydCBub3QgaXNfcHJpbWUoNCwgWzIsIDNdKQ0KDQpkZWYgc21hbGxlc3RfY29tbW9uX211bHRpcGxlX29mX2FsbF9udW1iZXJzX3VwX3RvKHgpOg0KICAgIGlmIHggPT0gMToNCiAgICAgICAgcmV0dXJuIDENCiAgICB5ID0gMQ0KICAgIHByaW1lcyA9IFtdDQogICAgZm9yIGkgaW4gcmFuZ2UoMiwgeCArIDEpOg0KICAgICAgICBpZiBpc19wcmltZShpLCBwcmltZXMpOg0KICAgICAgICAgICAgcHJpbWVzLmFwcGVuZChpKQ0KICAgICAgICAgICAgeSAqPSBpDQogICAgICAgICAgICBjb250aW51ZQ0KICAgICAgICBpZiB5ICUgaSA9PSAwOg0KICAgICAgICAgICAgY29udGludWUNCiAgICAgICAgZm9yIHAgaW4gcHJpbWVzOg0KICAgICAgICAgICAgaWYgKHkgKiBwKSAlIGkgPT0gMDoNCiAgICAgICAgICAgICAgICB5ICo9IHANCiAgICAgICAgICAgICAgICBicmVhaw0KICAgIHJldHVybiB5DQoNCmFzc2VydCBzbWFsbGVzdF9jb21tb25fbXVsdGlwbGVfb2ZfYWxsX251bWJlcnNfdXBfdG8oMykgPT0gNg0KYXNzZXJ0IHNtYWxsZXN0X2NvbW1vbl9tdWx0aXBsZV9vZl9hbGxfbnVtYmVyc191cF90bygxMCkgPT0gMjUyMA0KDQpwcmludCBzbWFsbGVzdF9jb21tb25fbXVsdGlwbGVfb2ZfYWxsX251bWJlcnNfdXBfdG8oMjAp"},"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
def is_prime(x, primes):
    for p in primes:
        if x % p == 0:
            return False
    return True

assert is_prime(3, [2])
assert not is_prime(4, [2, 3])

def smallest_common_multiple_of_all_numbers_up_to(x):
    if x == 1:
        return 1
    y = 1
    primes = []
    for i in range(2, x + 1):
        if is_prime(i, primes):
            primes.append(i)
            y *= i
            continue
        if y % i == 0:
            continue
        for p in primes:
            if (y * p) % i == 0:
                y *= p
                break
    return y

assert smallest_common_multiple_of_all_numbers_up_to(3) == 6
assert smallest_common_multiple_of_all_numbers_up_to(10) == 2520

print smallest_common_multiple_of_all_numbers_up_to(20)