Phương pháp thừa số nguyên tố python

def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
54 và
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
55 lần lượt thực hiện biến đổi Fourier và biến đổi Fourier ngược. Đối với
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
56 và
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
57 có độ dài
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
58, các phép biến đổi này được định nghĩa như sau

Y[k]=∑j=1nX[j] An[j−1]​[k−1]X[j]=1 n∑k=1nY[k] An−[j−1]​[k−1

ở đâu

là một trong n gốc của sự thống nhất

Vì không ai cố gắng hack điều này bằng phương pháp

def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
02 cũ, tôi sẽ lấy nghề này. Phương pháp này không linh hoạt cho các vấn đề như thế này bởi vì nó thực hiện vòng lặp của các hành động lặp lại trên mảng các đối số và không có cách nào để làm gián đoạn vòng lặp này theo mặc định. Cửa mở sau khi chúng tôi đã thực hiện
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
03 của riêng mình cho các vòng lặp bị gián đoạn như sau

Nội dung chính Hiển thị

  • [600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> Không 6[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839]
  • [600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> Không chia 6def[c]. num, start = c for i in range[start, int[num**0. 5]+1]. nếu số % tôi == 0. return [num//i, i] return Không có 8 [600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> Không có 28[600851475143, 2] -> [
  • Làm thế nào để bạn tìm thấy một yếu tố chính?
  • Làm thế nào để bạn tìm thấy nguyên tố của một chuỗi trong Python?
  • Có chức năng nguyên tố số chức năng trong Python không?
  • Làm thế nào để bạn tính đến một số trong Python?

from functools import reduce

def inner_func[func, cond, x, y]:
    res = func[x, y]
    if not cond[res]:
        raise StopIteration[x, y]
    return res

def ireducewhile[func, cond, iterable]:
    # generates intermediary results of args while reducing
    iterable = iter[iterable]
    x = next[iterable]
    yield x
    for y in iterable:
        try:
            x = inner_func[func, cond, x, y]
        except StopIteration:
            break
        yield x

Sau đó, chúng tôi có thể sử dụng một số

def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
04 giống như đầu vào của phương pháp giảm tiêu chuẩn python. Please to this thing has been verify by the way

def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None

Giả sử chúng tôi muốn nhân số 600851475143, đầu ra dự kiến ​​kiến ​​​​trúc của chức năng này sau khi sử dụng nhiều lần chức năng này phải là thế này

[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None

Mục đầu tiên của tuple là một số mà phương thức

def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
1 lấy và cố gắng chia cho ước số nhỏ nhất bắt đầu từ mục thứ hai và kết thúc với căn bậc hai của số này. Nếu không có số ước tính tồn tại, không có gì được trả lại. Bây giờ chúng ta cần bắt đầu với Iterator đã được xác định như thế này.
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0

The end, results of the loop is

________số 8

And ra the main value could be started by

if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]

Ghi chú

Để làm cho nó hiệu quả hơn, bạn có thể muốn sử dụng các nguyên tố số được tạo sẵn trong phạm vi công cụ có thể thay thế vì tất cả các giá trị của phạm vi này

Cho một số N, viết một chức năng hiệu quả cho tất cả các yếu tố chính của n. Ví dụ. if the first number to be 12, then the start must be 2 2 2 3. Và nếu số đầu vào là 315, thì đầu ra phải là 3 3 5 7 7. n, hãy viết một hàm hiệu quả để in tất cả các thừa số nguyên tố của n. Ví dụ: nếu số đầu vào là 12, thì đầu ra phải là “2 2 3”. Và nếu số đầu vào là 315, thì đầu ra phải là “3 3 5 7”

Cách tiếp cận đầu tiên

Sau đây là các bước để tìm tất cả các yếu tố chính.   .   . Bây giờ bắt đầu một vòng từ I = 3 đến cấp hai của n. Trong khi tôi chia n, in i và chia n cho tôi. Sau khi tôi không chia sẻ, tăng tôi cho 2 và tiếp tục.   . Vì vậy, trong n nếu nó lớn hơn 2.  
1] Trong khi n chia hết cho 2, in 2 và chia n cho 2.
2] Sau bước 1, n phải là số lẻ. Bây giờ bắt đầu một vòng lặp từ i = 3 đến căn bậc hai của n. Trong khi tôi chia n, in ra i và chia n cho i. Sau khi i không chia được n, hãy tăng i lên 2 và tiếp tục.
3] Nếu n là số nguyên tố và lớn hơn 2 thì n sẽ không trở thành 1 theo hai bước trên. Vì vậy, in n nếu nó lớn hơn 2.

C++

def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
2
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
3
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
4
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
5
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
6
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
7
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
8
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
9
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
0
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
2
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
3
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
0
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
7
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
8
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
9
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
1
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
5
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
6
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
8
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
8
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
9
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
0
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
0
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
2
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
5
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
0
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
8
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
9
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
8
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
9
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
8
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
3
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
9
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
50
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
52
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
8
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
9
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
8
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
57
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
0
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
8
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
021
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
023
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
025
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
026
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3

C

def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
028

def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
029

def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
6
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
7
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
8
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
9
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
0
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
2
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
3
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
0
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
041
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
6
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
043
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
044
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
1
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
5
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
6
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
8
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
8
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
9
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
0
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
0
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
2
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
5
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
0
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
8
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
041
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
6
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
043
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
17
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
8
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
3
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
9
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
50
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
8
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
57
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
8
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
57
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
0
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
8
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
021
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
023
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
025
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
026
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3

C

[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
2
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
037_______51
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
5
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
6
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
8
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
8
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
9
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
05
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
2
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
10
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
0
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
041
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
6
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
043
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
31
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
0

Java

[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
0
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
45
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
46
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
8
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
77
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
64
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
9
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
45
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
48
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
49
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
50
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
53
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
54
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
6
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
7
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
8
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
9
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
8
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
0

[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
00
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
01
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
8
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
75
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
00
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
05
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
8
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
2
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
63
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
64
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
65
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
66
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
67
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
8
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
16
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
8
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
71
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
64
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
73
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
8
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
75
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
0
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
5
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
6
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
8
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
86
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
87
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
88__
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
023
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3

[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> Không 6[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839]

result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
8
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
2
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
95
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
66
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
67
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
9
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1212
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
64
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
67
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
53
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
54
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
6
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
23
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
8
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
28
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
29
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
9

con trăn

def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
45
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
37
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
38
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
39
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
2_______542
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
43
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
64
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
45
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
45
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
66__
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
50
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
64
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
52
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
42
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
45
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
42
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
57
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
64

Các

[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
2____542
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
43
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
78
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
45
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
45
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
66__
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
03

C#

result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
8
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
50
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
85
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
8
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
42
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
45
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
42
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
57
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
78
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
0
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
9
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
94
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
64
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
48
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
12
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
041
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
6
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
043
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
31
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
0

Java

[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
0
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
8
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
28
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
8
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
75
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
45
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
46
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
45
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
48
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
0
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
49
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
50
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
8
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
0
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
00
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
48
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
8
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
75
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
00
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
05
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
8
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
9
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
50
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
8
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
61
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
53
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
54
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
6
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
68
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
0
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
8
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
021
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
023
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3

PHP

def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
80
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
81
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
7
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
83
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
67
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
0
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
2
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
6
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
83
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
90
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
0
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
94
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
95
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
8
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
9
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
83
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
00
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
83
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
02
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
5
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
6
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
08
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
09
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
08
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
14
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
08
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
00
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
08
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
18
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
0
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
2
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
6
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
83
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
25
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
08
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
27
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
0
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
8
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
94
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
08
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
525____28
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
9
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
8
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
83
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
00
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
83
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
40
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
08
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
9
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
9
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
6
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
83
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
51
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
94
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
83
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
525____28
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
9
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
83
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
61

[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
7
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
83
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
75
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
66

JavaScript

result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
67
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
81
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
03
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
0
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
2
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
3
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
0
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
77
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
8
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
75
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
81
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
5
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
86
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
8
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
88
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
8
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
90
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
0
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
2
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
5
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
0
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
8
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
99
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
8
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
75
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
8
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
03
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
9
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
50
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
12
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
8
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
75
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
16

def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
023

if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
18

đầu ra.  

result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
5

Độ phức tạp về thời gian. O [SQRT [N]]O[sqrt[n]]

Trong trường hợp xấu nhất [khi n hoặc sqrt [n] là số nguyên tố, ví dụ. lấy n = 11 hoặc n = 121 cho cả hai trường hợp cho vòng lặp chạy sqrt [n] lần] lần. Càng nhiều vòng lặp trong khi lặp lại trên một số mà nó làm giảm n ban đầu, điều này cũng làm giảm giá trị của sqrt [n]. Mặc dù độ phức tạp của thời gian trường hợp tốt nhất là O [log [n]], khi các yếu tố chính của n chỉ là 2 và 3 hoặc n có dạng [2^x*[3^y] trong đó x>

Không hỗ trợ khoảng thời gian. Ô [1] Ô[1]

Điều này hoạt động như thế nào? . Để chứng minh rằng thuật toán hoàn chỉnh hoạt động, chúng ta cần chứng minh rằng các bước 1 và 2 thực sự chăm sóc các tổng hợp. Điều này rõ ràng là Bước 1 chăm sóc các số lượng ngày. Và sau bước 1, tất cả các yếu tố chính còn lại phải là lẻ [chênh lệch hai yếu tố chính ít nhất phải là 2], điều này giải thích lý do tại sao tôi được tăng lên 2.   . Để chứng minh rằng thuật toán hoàn chỉnh hoạt động, chúng ta cần chứng minh rằng bước 1 và bước 2 thực sự quan tâm đến các hợp số. Điều này rõ ràng là bước 1 chăm sóc các số chẵn. Và sau bước 1, tất cả các thừa số nguyên tố còn lại phải là số lẻ [hiệu của 2 thừa số nguyên tố ít nhất là 2], điều này giải thích tại sao i được tăng thêm 2.
The steps 1 and 2 take care of composite numbers and step 3 takes care of prime numbers. To prove that the complete algorithm works, we need to prove that steps 1 and 2 actually take care of composite numbers. This is clear that step 1 takes care of even numbers. And after step 1, all remaining prime factors must be odd [difference of two prime factors must be at least 2], this explains why i is incremented by 2. 

Bây giờ phần chính là, vòng lặp chạy đến căn bậc hai của N cho đến khi n. Để chứng minh rằng sự tối ưu hóa hoạt động này, chúng ta hãy xem xét thuộc tính sau của tổng hợp.  

Elemental total Có ít nhất yếu tố nguyên tố nhỏ hơn hoặc bằng với căn bậc hai của chính nó.   . Set a and b is two elements of n sao cho a*b = n. If both two both large than √n, then a. b> √n, * √n, điều này đặt vật liệu với biểu thức là A * b = n, & nbsp;
Tính chất này có thể được chứng minh bằng cách sử dụng câu lệnh phản chứng. Gọi a và b là hai thừa số của n sao cho a*b = n. Nếu cả hai đều lớn hơn √n, thì a. b > √n, * √n, mâu thuẫn với biểu thức “a * b = n”.

Trong bước 2 của thuật toán trên, chúng tôi chạy một vòng lặp và thực hiện các mục sau trong vòng lặp & nbsp; .   . Các bước a và b được lặp lại cho đến khi n trở thành 1 hoặc nguyên tố.
a] Tìm thừa số nguyên tố nhỏ nhất i [phải nhỏ hơn √n,] 
b] Loại bỏ tất cả các lần xuất hiện i khỏi n bằng cách chia n nhiều lần cho i.
c] Lặp lại bước a và b để chia cho n và i = i + 2. Các bước a và b được lặp lại cho đến khi n trở thành 1 hoặc số nguyên tố.

Cách tiếp cận thứ hai. Cách tiếp cận này tương tự như sẵn có của Eratosthenes

Chúng ta có thể đạt được O [log n] cho tất cả các tổng số bằng cách chia số liên tiếp của số đã cho bằng một số nguyên bắt đầu từ 2 đại diện cho số hiện tại của số đó. Cách tiếp cận này hoạt động trên thực tế là tất cả các tổng hợp đều có các yếu tố tố theo cặp không phải là 1 hoặc các số như 6 = 3 x 2 và 9 = 3 x 3 trong khi đối chiếu với các nguyên tố không.

Do đó, nếu chúng ta bắt đầu chia số cho số nguyên tố nhỏ nhất có thể [2] thì tất cả các số bội số hoặc số tổng hợp của nó sẽ tự động bị xóa trước khi chúng tôi thực sự đạt được số đó

Ví dụ. Chúng ta có thể chia 12 cho 2 lần và loại bỏ các yếu tố đó từ 12 để nhận 3 do đó chắc chắn rằng tổng số 4 [bộ 2] không xảy ra ở bất kỳ thời điểm nào sau đây

Tương tự, nếu chúng ta có một số lượng lớn không chia hết cho bất kỳ giá trị nào của C = 2 đến N-1 có nghĩa là nó là số nguyên tố như 13 [không chia hết từ 2 đến 12]

C++14

def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
2
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
3
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
4
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
5
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
6
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
7
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
8
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
9
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
0
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
8
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
30
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
2
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
33
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
0
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
9
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
38
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
40
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
8
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
9
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
44
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
48
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
49
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
8
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
57
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
0
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
8
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
021
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
023
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
025
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
026
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3

C

if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
65
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
6
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
7
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
8
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
9
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
0
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
8
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
30
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
48
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
49
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
8
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
57
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
80
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
041
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
6
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
043
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
84
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
80
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
86
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
48
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
80
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
49
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
8
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
021
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
8
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
57
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
0
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
8
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
021
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
71
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
023

[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1____0025
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
026
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3

C

if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
71
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
8
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
73
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
71
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
2
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
76
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
9
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
79
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
0
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
71
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
71
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
8
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
021
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
71
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
025
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
026

Java

[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
00
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
86
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
8
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
8
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
48_______500
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
49
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
45
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
509
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
0
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
49
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
511
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
023
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3

C#

[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
53
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
54
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
6
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
7
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
8
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
9
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
71
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
2
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
76
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
9
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
79
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
0
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
71
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
71
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
8
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
021
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
71
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
025
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
026
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
00
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
591
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
8
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
75
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
00
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
86
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
8
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
8
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
48
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
00
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
49
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3

Java

[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
0
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
45_______8509
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
023
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
49
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
511
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3

Python3

[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
53
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
54
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
6
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
7
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
8
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
9
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
8
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
523
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
64
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
9
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
2
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
12
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
70
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
73
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
2
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1212____270
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
530
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
8
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
50
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
0246
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
45
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
8
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
67
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
8
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
9
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
533
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
666
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
530
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
48
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
48
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
00
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
537
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
8
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
75
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
53
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
54
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
6
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
556
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
03

[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> Không chia 6def[c]. num, start = c for i in range[start, int[num**0. 5]+1]. nếu số % tôi == 0. return [num//i, i] return Không có 8 [600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> Không có 28[600851475143, 2] -> [

result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
67
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
3
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
05
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
0
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
0274
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
2
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
0277
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
0
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
9
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
0282
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
8
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
0284
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
8
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
75
result = list[ireducewhile[lambda x,y: div[x], lambda x: x is not None, iterable=gen[600851475143]]]
#result: [[600851475143, 2], [8462696833, 71], [10086647, 839], [6857, 1471]]
8
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
86
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
def gener[prime]:
    # returns and infinite generator [600851475143, 2], 0, 0, 0...
    yield [prime, 2]
    while True:
        yield 0
3
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
6
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
48
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
49
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
1_____73_____1

def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
023

if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
18

if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
901
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
54
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
6
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
7
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
8
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
9Phương pháp tiếp cận này là tốt nhất cho tất cả các số hỗn hợp và đạt được O[log n] nhưng ngược lại là O[n]

if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
906
def division[c]:
    num, start = c
    for i in range[start, int[num**0.5]+1]:
        if num % i == 0:
            return [num//i, i]
    return None
8
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
73 O[1]

if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
906
[600851475143, 2] -> [8462696833 -> 71], [10086647 -> 839], [6857, 1471] -> None
2
if len[result] == 1: output = result[0][0]
else: output = list[map[lambda x: x[1], result[1:]]]+[result[-1][0]]
#output: [2, 71, 839, 1471]
76
Lập thừa số nguyên tố bằng cách sử dụng Sàng O[log n] cho nhiều truy vấn
Cảm ơn Vishwas Garg đã đề xuất thuật toán trên. Vui lòng viết nhận xét nếu bạn thấy có gì không đúng hoặc bạn muốn chia sẻ thêm thông tin về chủ đề đã thảo luận ở trên
 

Làm thế nào để bạn tìm thấy một yếu tố chính

Thuật toán đơn giản nhất để tìm các yếu tố chính của một số đang tiếp tục chia số ban đầu cho các yếu tố chính cho đến khi chúng ta có phần còn lại bằng 1. Ví dụ. các yếu tố chính của chúng ta nhận được, 30/2 = 15, 15/15/ 3 = 5, 5/5 = 1. tiếp tục chia số ban đầu cho các thừa số nguyên tố cho đến khi chúng ta nhận được phần còn lại bằng 1 . Ví dụ, phân tích ra thừa số nguyên tố của số 30 ta được 30/2 = 15, 15/3 = 5, 5/5 = 1.

Làm thế nào để bạn tìm thấy nguyên tố của một chuỗi trong Python?

Bước 1. Vòng lặp qua tất cả các yếu tố trong phạm vi đã chọn. Bước 2. Kiểm tra từng số nếu nó có bất kỳ yếu tố nào giữa 1 và chính nó. Bước 3. Nếu có, thì số không phải là số nguyên tố và nó sẽ chuyển sang số tiếp theo. Bước 4. Nếu không, đó là số chính và chương trình sẽ ở trong đó và kiểm tra số tiếp theo

Chủ Đề