Hướng dẫn proper positive divisors python - số chia dương thích hợp python

Cập nhật lần cuối vào ngày 19 tháng 8 năm 2022 21:50:47 (UTC/GMT +8 giờ)

Chức năng Python: Bài tập-11 với giải pháp

Viết chức năng Python để kiểm tra xem một số có hoàn hảo hay không.

Show

Theo Wikipedia: Theo lý thuyết số, một số hoàn hảo là một số nguyên dương bằng tổng số các giao diện dương hợp lý của nó, nghĩa là tổng số các giao diện dương của nó không bao gồm chính số (còn được gọi là tổng hợp của nó). Tương tự, một số hoàn hảo là một số là một nửa tổng của tất cả các ước số dương của nó (bao gồm cả chính nó). Ví dụ & NBSP; 1 + 2 + 3 + 6) / 2 = 6. Số hoàn hảo tiếp theo là 28 = 1 + 2 + 4 + 7 + 14. Điều này được theo sau bởi các số hoàn hảo 496 và 8128.
Example : The first perfect number is 6, because 1, 2, and 3 are its proper positive divisors, and 1 + 2 + 3 = 6. Equivalently, the number 6 is equal to half the sum of all its positive divisors: ( 1 + 2 + 3 + 6 ) / 2 = 6. The next perfect number is 28 = 1 + 2 + 4 + 7 + 14. This is followed by the perfect numbers 496 and 8128.

Giải pháp mẫu:-:-

Mã Python:

def perfect_number(n):
    sum = 0
    for x in range(1, n):
        if n % x == 0:
            sum += x
    return sum == n
print(perfect_number(6))
 

Đầu ra mẫu:

True

Trình bày bằng hình ảnh:

Hướng dẫn proper positive divisors python - số chia dương thích hợp python

Sơ đồ:

Hướng dẫn proper positive divisors python - số chia dương thích hợp python

Trực quan hóa thực thi mã Python:

Công cụ sau đây trực quan hóa những gì máy tính đang làm từng bước khi nó thực hiện chương trình đã nói:

Trình chỉnh sửa mã Python:

Có một cách khác để giải quyết giải pháp này? Đóng góp mã của bạn (và nhận xét) thông qua Disqus.

Trước đây: Viết chương trình Python để in các số chẵn từ một danh sách đã cho. Write a Python program to print the even numbers from a given list.
Next: Write a Python function that checks whether a passed string is palindrome or not.

True 6>>> import collections >>> A = collections.Counter([1, 1, 2, 2, 3, 3, 3, 3, 4, 5, 6, 7]) >>> A Counter({3: 4, 1: 2, 2: 2, 4: 1, 5: 1, 6: 1, 7: 1}) >>> A.most_common(1) [(3, 4)] >>> A.most_common(3) [(3, 4), (1, 2), (2, 2)] 2 >>> import collections >>> A = collections.Counter([1, 1, 2, 2, 3, 3, 3, 3, 4, 5, 6, 7]) >>> A Counter({3: 4, 1: 2, 2: 2, 4: 1, 5: 1, 6: 1, 7: 1}) >>> A.most_common(1) [(3, 4)] >>> A.most_common(3) [(3, 4), (1, 2), (2, 2)] 3Input: n = 15 Output: false Divisors of 15 are 1, 3 and 5. Sum of divisors is 9 which is not equal to 15. Input: n = 6 Output: true Divisors of 6 are 1, 2 and 3. Sum of divisors is 6.37 Input: n = 15 Output: false Divisors of 15 are 1, 3 and 5. Sum of divisors is 9 which is not equal to 15. Input: n = 6 Output: true Divisors of 6 are 1, 2 and 3. Sum of divisors is 6.38__

Input: n = 15
Output: false
Divisors of 15 are 1, 3 and 5. Sum of 
divisors is 9 which is not equal to 15.

Input: n = 6
Output: true
Divisors of 6 are 1, 2 and 3. Sum of 
divisors is 6.
0
Input: n = 15
Output: false
Divisors of 15 are 1, 3 and 5. Sum of 
divisors is 9 which is not equal to 15.

Input: n = 6
Output: true
Divisors of 6 are 1, 2 and 3. Sum of 
divisors is 6.
1
>>> import collections

>>> A = collections.Counter([1, 1, 2, 2, 3, 3, 3, 3, 4, 5, 6, 7])
>>> A
Counter({3: 4, 1: 2, 2: 2, 4: 1, 5: 1, 6: 1, 7: 1})
>>> A.most_common(1)
[(3, 4)]
>>> A.most_common(3)
[(3, 4), (1, 2), (2, 2)]
3
Input: n = 15
Output: false
Divisors of 15 are 1, 3 and 5. Sum of 
divisors is 9 which is not equal to 15.

Input: n = 6
Output: true
Divisors of 6 are 1, 2 and 3. Sum of 
divisors is 6.
28
Input: n = 15
Output: false
Divisors of 15 are 1, 3 and 5. Sum of 
divisors is 9 which is not equal to 15.

Input: n = 6
Output: true
Divisors of 6 are 1, 2 and 3. Sum of 
divisors is 6.
53
Input: n = 15
Output: false
Divisors of 15 are 1, 3 and 5. Sum of 
divisors is 9 which is not equal to 15.

Input: n = 6
Output: true
Divisors of 6 are 1, 2 and 3. Sum of 
divisors is 6.
37
Input: n = 15
Output: false
Divisors of 15 are 1, 3 and 5. Sum of 
divisors is 9 which is not equal to 15.

Input: n = 6
Output: true
Divisors of 6 are 1, 2 and 3. Sum of 
divisors is 6.
55

Input: n = 15
Output: false
Divisors of 15 are 1, 3 and 5. Sum of 
divisors is 9 which is not equal to 15.

Input: n = 6
Output: true
Divisors of 6 are 1, 2 and 3. Sum of 
divisors is 6.
5
Input: n = 15
Output: false
Divisors of 15 are 1, 3 and 5. Sum of 
divisors is 9 which is not equal to 15.

Input: n = 6
Output: true
Divisors of 6 are 1, 2 and 3. Sum of 
divisors is 6.
1
>>> import collections

>>> A = collections.Counter([1, 1, 2, 2, 3, 3, 3, 3, 4, 5, 6, 7])
>>> A
Counter({3: 4, 1: 2, 2: 2, 4: 1, 5: 1, 6: 1, 7: 1})
>>> A.most_common(1)
[(3, 4)]
>>> A.most_common(3)
[(3, 4), (1, 2), (2, 2)]
3
Input: n = 15
Output: false
Divisors of 15 are 1, 3 and 5. Sum of 
divisors is 9 which is not equal to 15.

Input: n = 6
Output: true
Divisors of 6 are 1, 2 and 3. Sum of 
divisors is 6.
37
Input: n = 15
Output: false
Divisors of 15 are 1, 3 and 5. Sum of 
divisors is 9 which is not equal to 15.

Input: n = 6
Output: true
Divisors of 6 are 1, 2 and 3. Sum of 
divisors is 6.
40
Input: n = 15
Output: false
Divisors of 15 are 1, 3 and 5. Sum of 
divisors is 9 which is not equal to 15.

Input: n = 6
Output: true
Divisors of 6 are 1, 2 and 3. Sum of 
divisors is 6.
37
Input: n = 15
Output: false
Divisors of 15 are 1, 3 and 5. Sum of 
divisors is 9 which is not equal to 15.

Input: n = 6
Output: true
Divisors of 6 are 1, 2 and 3. Sum of 
divisors is 6.
64
Input: n = 15
Output: false
Divisors of 15 are 1, 3 and 5. Sum of 
divisors is 9 which is not equal to 15.

Input: n = 6
Output: true
Divisors of 6 are 1, 2 and 3. Sum of 
divisors is 6.
28__

Xem thảo luận

Cải thiện bài viết

Lưu bài viết

  • Đọc
  • Bàn luận
  • Xem thảo luận

    Cải thiện bài viết

    Lưu bài viết

    Đọc
    Examples: 

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.

    Bàn luậnSimple Solution is to go through every number from 1 to n-1 and check if it is a divisor. Maintain sum of all divisors. If sum becomes equal to n, then return true, else return false.
    An Efficient Solution is to go through numbers till square root of n. If a number ‘i’ divides n, then add both ‘i’ and n/i to sum. 
    Below is the implementation of efficient solution. 
     

    C++

    #include<iostream>

    Một số là một con số hoàn hảo nếu bằng tổng số các giao diện thích hợp của nó, nghĩa là tổng số các ước số dương của nó không bao gồm chính số. Viết một hàm để kiểm tra xem một số đã cho có hoàn hảo hay không. & NBSP; Ví dụ: & nbsp;

    Một giải pháp đơn giản là đi qua mỗi số từ 1 đến N-1 và kiểm tra xem đó có phải là một ước số không. Duy trì tổng của tất cả các ước. Nếu tổng trở nên bằng n, thì trả về true, nếu không trả về false. Một giải pháp hiệu quả là đi qua các số cho đến căn bậc hai của n. Nếu một số ‘I, chia n, thì hãy thêm cả‘ I, và N/I vào tổng. & Nbsp; bên dưới là việc thực hiện giải pháp hiệu quả. & Nbsp; & nbsp;

    True
    
    5

    using namespace std;

    bool

    True
    
    0
    True
    
    1
    True
    
    1
    True
    
    3
    True
    
    4

    True
    
    6
    True
    
    5

    True
    
    6
    True
    
    1
    True
    
    1
    True
    
    3
    >>> import collections
    
    >>> A = collections.Counter([1, 1, 2, 2, 3, 3, 3, 3, 4, 5, 6, 7])
    >>> A
    Counter({3: 4, 1: 2, 2: 2, 4: 1, 5: 1, 6: 1, 7: 1})
    >>> A.most_common(1)
    [(3, 4)]
    >>> A.most_common(3)
    [(3, 4), (1, 2), (2, 2)]
    
    0

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    0
    True
    
    5

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    5
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    1
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    7

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    8
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    9

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    5
    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    1

    True
    
    6
    >>> import collections
    
    >>> A = collections.Counter([1, 1, 2, 2, 3, 3, 3, 3, 4, 5, 6, 7])
    >>> A
    Counter({3: 4, 1: 2, 2: 2, 4: 1, 5: 1, 6: 1, 7: 1})
    >>> A.most_common(1)
    [(3, 4)]
    >>> A.most_common(3)
    [(3, 4), (1, 2), (2, 2)]
    
    2
    >>> import collections
    
    >>> A = collections.Counter([1, 1, 2, 2, 3, 3, 3, 3, 4, 5, 6, 7])
    >>> A
    Counter({3: 4, 1: 2, 2: 2, 4: 1, 5: 1, 6: 1, 7: 1})
    >>> A.most_common(1)
    [(3, 4)]
    >>> A.most_common(3)
    [(3, 4), (1, 2), (2, 2)]
    
    3
    True
    
    1
    True
    
    1
    True
    
    3
    >>> import collections
    
    >>> A = collections.Counter([1, 1, 2, 2, 3, 3, 3, 3, 4, 5, 6, 7])
    >>> A
    Counter({3: 4, 1: 2, 2: 2, 4: 1, 5: 1, 6: 1, 7: 1})
    >>> A.most_common(1)
    [(3, 4)]
    >>> A.most_common(3)
    [(3, 4), (1, 2), (2, 2)]
    
    7

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    0
    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    5

    True
    
    6
    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    5

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    0
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    1
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    2

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    8
    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    3

    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    8
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    1 #include<iostream>0

    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    5

    #include<iostream>1#include<iostream>2 #include<iostream>3#include<iostream>4

    True
    
    5

    True
    
    6using4using5#include<iostream>4

    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    8#include<iostream>2 #include<iostream>7#include<iostream>4

    True
    
    3 using1

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    5namespace6namespace7#include<iostream>4

    True
    
    6
    >>> import collections
    
    >>> A = collections.Counter([1, 1, 2, 2, 3, 3, 3, 3, 4, 5, 6, 7])
    >>> A
    Counter({3: 4, 1: 2, 2: 2, 4: 1, 5: 1, 6: 1, 7: 1})
    >>> A.most_common(1)
    [(3, 4)]
    >>> A.most_common(3)
    [(3, 4), (1, 2), (2, 2)]
    
    2
    >>> import collections
    
    >>> A = collections.Counter([1, 1, 2, 2, 3, 3, 3, 3, 4, 5, 6, 7])
    >>> A
    Counter({3: 4, 1: 2, 2: 2, 4: 1, 5: 1, 6: 1, 7: 1})
    >>> A.most_common(1)
    [(3, 4)]
    >>> A.most_common(3)
    [(3, 4), (1, 2), (2, 2)]
    
    3
    True
    
    3 namespace1

    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    5

    Input: n = 15 Output: false Divisors of 15 are 1, 3 and 5. Sum of divisors is 9 which is not equal to 15. Input: n = 6 Output: true Divisors of 6 are 1, 2 and 3. Sum of divisors is 6.0Input: n = 15 Output: false Divisors of 15 are 1, 3 and 5. Sum of divisors is 9 which is not equal to 15. Input: n = 6 Output: true Divisors of 6 are 1, 2 and 3. Sum of divisors is 6.1 namespace4

    True
    
    6#include<iostream>2 std;1

    Java

    std;3 std;4

    True
    
    5

    True
    
    5

    std;6 std;7

    True
    
    0
    True
    
    3
    True
    
    4

    True
    
    6
    True
    
    5

    True
    
    6
    True
    
    3 bool4bool5#include<iostream>4

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    0
    True
    
    5

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    5
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    1
    True
    
    15

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    8
    True
    
    17

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    5
    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    1

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    8
    True
    
    21

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    0
    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    5

    True
    
    6
    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    5

    True
    
    6
    >>> import collections
    
    >>> A = collections.Counter([1, 1, 2, 2, 3, 3, 3, 3, 4, 5, 6, 7])
    >>> A
    Counter({3: 4, 1: 2, 2: 2, 4: 1, 5: 1, 6: 1, 7: 1})
    >>> A.most_common(1)
    [(3, 4)]
    >>> A.most_common(3)
    [(3, 4), (1, 2), (2, 2)]
    
    2
    >>> import collections
    
    >>> A = collections.Counter([1, 1, 2, 2, 3, 3, 3, 3, 4, 5, 6, 7])
    >>> A
    Counter({3: 4, 1: 2, 2: 2, 4: 1, 5: 1, 6: 1, 7: 1})
    >>> A.most_common(1)
    [(3, 4)]
    >>> A.most_common(3)
    [(3, 4), (1, 2), (2, 2)]
    
    3
    True
    
    3
    True
    
    01
    True
    
    022

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    0
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    1
    True
    
    08
    True
    
    09
    True
    
    10

    True
    
    6
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    1
    True
    
    28bool5
    True
    
    10

    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    5

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    0____52 #include<iostream>3#include<iostream>4

    True
    
    5

    True
    
    6#include<iostream>2 #include<iostream>7#include<iostream>4

    True
    
    49
    True
    
    50
    True
    
    51

    True
    
    40 std;6
    True
    
    42
    True
    
    43

    True
    
    3 using1

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    5
    True
    
    65

    True
    
    66
    True
    
    67
    True
    
    51

    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    5

    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    5

    Python3

    True
    
    6
    >>> import collections
    
    >>> A = collections.Counter([1, 1, 2, 2, 3, 3, 3, 3, 4, 5, 6, 7])
    >>> A
    Counter({3: 4, 1: 2, 2: 2, 4: 1, 5: 1, 6: 1, 7: 1})
    >>> A.most_common(1)
    [(3, 4)]
    >>> A.most_common(3)
    [(3, 4), (1, 2), (2, 2)]
    
    2
    >>> import collections
    
    >>> A = collections.Counter([1, 1, 2, 2, 3, 3, 3, 3, 4, 5, 6, 7])
    >>> A
    Counter({3: 4, 1: 2, 2: 2, 4: 1, 5: 1, 6: 1, 7: 1})
    >>> A.most_common(1)
    [(3, 4)]
    >>> A.most_common(3)
    [(3, 4), (1, 2), (2, 2)]
    
    3
    True
    
    3 namespace1

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    0
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    1 namespace4

    True
    
    6#include<iostream>2 std;1

    Java

    std;3 std;4

    True
    
    5

    std;6 std;7

    True
    
    0
    True
    
    3
    True
    
    4

    True
    
    6
    True
    
    3 bool4bool5#include<iostream>4

    True
    
    6
    >>> import collections
    
    >>> A = collections.Counter([1, 1, 2, 2, 3, 3, 3, 3, 4, 5, 6, 7])
    >>> A
    Counter({3: 4, 1: 2, 2: 2, 4: 1, 5: 1, 6: 1, 7: 1})
    >>> A.most_common(1)
    [(3, 4)]
    >>> A.most_common(3)
    [(3, 4), (1, 2), (2, 2)]
    
    2
    >>> import collections
    
    >>> A = collections.Counter([1, 1, 2, 2, 3, 3, 3, 3, 4, 5, 6, 7])
    >>> A
    Counter({3: 4, 1: 2, 2: 2, 4: 1, 5: 1, 6: 1, 7: 1})
    >>> A.most_common(1)
    [(3, 4)]
    >>> A.most_common(3)
    [(3, 4), (1, 2), (2, 2)]
    
    3
    True
    
    3
    True
    
    01
    True
    
    022

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    0
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    1
    True
    
    08
    True
    
    09
    True
    
    10

    True
    
    6
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    1
    True
    
    28bool5
    True
    
    10

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    0____52 #include<iostream>3#include<iostream>4

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    0
    >>> import collections
    
    >>> A = collections.Counter([1, 1, 2, 2, 3, 3, 3, 3, 4, 5, 6, 7])
    >>> A
    Counter({3: 4, 1: 2, 2: 2, 4: 1, 5: 1, 6: 1, 7: 1})
    >>> A.most_common(1)
    [(3, 4)]
    >>> A.most_common(3)
    [(3, 4), (1, 2), (2, 2)]
    
    28
    >>> import collections
    
    >>> A = collections.Counter([1, 1, 2, 2, 3, 3, 3, 3, 4, 5, 6, 7])
    >>> A
    Counter({3: 4, 1: 2, 2: 2, 4: 1, 5: 1, 6: 1, 7: 1})
    >>> A.most_common(1)
    [(3, 4)]
    >>> A.most_common(3)
    [(3, 4), (1, 2), (2, 2)]
    
    47
    True
    
    67
    True
    
    10

    C#

    True
    
    6#include<iostream>2 std;1

    True
    
    5

    Java

    True
    
    5

    std;3 std;4

    True
    
    5

    True
    
    6
    True
    
    5

    std;6 std;7

    True
    
    0
    True
    
    3
    True
    
    4

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    0
    True
    
    5

    True
    
    6
    True
    
    3 bool4bool5#include<iostream>4

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    8
    True
    
    17

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    5
    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    1

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    8
    True
    
    21

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    0
    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    5

    True
    
    6
    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    5

    True
    
    6
    >>> import collections
    
    >>> A = collections.Counter([1, 1, 2, 2, 3, 3, 3, 3, 4, 5, 6, 7])
    >>> A
    Counter({3: 4, 1: 2, 2: 2, 4: 1, 5: 1, 6: 1, 7: 1})
    >>> A.most_common(1)
    [(3, 4)]
    >>> A.most_common(3)
    [(3, 4), (1, 2), (2, 2)]
    
    2
    >>> import collections
    
    >>> A = collections.Counter([1, 1, 2, 2, 3, 3, 3, 3, 4, 5, 6, 7])
    >>> A
    Counter({3: 4, 1: 2, 2: 2, 4: 1, 5: 1, 6: 1, 7: 1})
    >>> A.most_common(1)
    [(3, 4)]
    >>> A.most_common(3)
    [(3, 4), (1, 2), (2, 2)]
    
    3
    True
    
    3
    True
    
    01
    True
    
    022

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    0
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    1
    True
    
    08
    True
    
    09
    True
    
    10

    True
    
    6
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    1
    True
    
    28bool5
    True
    
    10

    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    5

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    0____52 #include<iostream>3#include<iostream>4

    True
    
    5

    True
    
    6#include<iostream>2 #include<iostream>7#include<iostream>4

    True
    
    49
    True
    
    50
    True
    
    51

    True
    
    40 std;6
    True
    
    42
    True
    
    43

    True
    
    3 using1

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    5
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    19

    True
    
    66
    True
    
    67
    True
    
    51

    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    5

    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    5

    True 6>>> import collections >>> A = collections.Counter([1, 1, 2, 2, 3, 3, 3, 3, 4, 5, 6, 7]) >>> A Counter({3: 4, 1: 2, 2: 2, 4: 1, 5: 1, 6: 1, 7: 1}) >>> A.most_common(1) [(3, 4)] >>> A.most_common(3) [(3, 4), (1, 2), (2, 2)] 2 >>> import collections >>> A = collections.Counter([1, 1, 2, 2, 3, 3, 3, 3, 4, 5, 6, 7]) >>> A Counter({3: 4, 1: 2, 2: 2, 4: 1, 5: 1, 6: 1, 7: 1}) >>> A.most_common(1) [(3, 4)] >>> A.most_common(3) [(3, 4), (1, 2), (2, 2)] 3True 3 namespace1

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    25

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    0
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    1 namespace4

    True
    
    5

    True
    
    6#include<iostream>2 std;1

    Java

    True
    
    6
    True
    
    5

    std;3 std;4

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    0
    True
    
    5

    True
    
    5

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    8
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    32
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    69
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    32
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    71
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    37
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    73
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    28

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    5
    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    1

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    8
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    32
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    69
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    32
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    71
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    37#include<iostream>4

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    0
    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    5

    True
    
    6
    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    5

    True
    
    6
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    1
    >>> import collections
    
    >>> A = collections.Counter([1, 1, 2, 2, 3, 3, 3, 3, 4, 5, 6, 7])
    >>> A
    Counter({3: 4, 1: 2, 2: 2, 4: 1, 5: 1, 6: 1, 7: 1})
    >>> A.most_common(1)
    [(3, 4)]
    >>> A.most_common(3)
    [(3, 4), (1, 2), (2, 2)]
    
    3
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    32
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    95
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    28

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    0#include<iostream>2
    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    02

    True
    
    6#include<iostream>2
    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    05

    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    5

    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    07 using5#include<iostream>4

    >>> import collections
    
    >>> A = collections.Counter([1, 1, 2, 2, 3, 3, 3, 3, 4, 5, 6, 7])
    >>> A
    Counter({3: 4, 1: 2, 2: 2, 4: 1, 5: 1, 6: 1, 7: 1})
    >>> A.most_common(1)
    [(3, 4)]
    >>> A.most_common(3)
    [(3, 4), (1, 2), (2, 2)]
    
    2
    >>> import collections
    
    >>> A = collections.Counter([1, 1, 2, 2, 3, 3, 3, 3, 4, 5, 6, 7])
    >>> A
    Counter({3: 4, 1: 2, 2: 2, 4: 1, 5: 1, 6: 1, 7: 1})
    >>> A.most_common(1)
    [(3, 4)]
    >>> A.most_common(3)
    [(3, 4), (1, 2), (2, 2)]
    
    3
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    28
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    38
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    28
    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    15
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    28
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    46

    True
    
    6
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    1
    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    20
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    28
    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    22

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    0
    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    07
    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    25#include<iostream>4

    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    27

    JavaScript

    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    28

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    26
    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    30

    True
    
    5

    True
    
    6
    >>> import collections
    
    >>> A = collections.Counter([1, 1, 2, 2, 3, 3, 3, 3, 4, 5, 6, 7])
    >>> A
    Counter({3: 4, 1: 2, 2: 2, 4: 1, 5: 1, 6: 1, 7: 1})
    >>> A.most_common(1)
    [(3, 4)]
    >>> A.most_common(3)
    [(3, 4), (1, 2), (2, 2)]
    
    0

    True
    
    6
    >>> import collections
    
    >>> A = collections.Counter([1, 1, 2, 2, 3, 3, 3, 3, 4, 5, 6, 7])
    >>> A
    Counter({3: 4, 1: 2, 2: 2, 4: 1, 5: 1, 6: 1, 7: 1})
    >>> A.most_common(1)
    [(3, 4)]
    >>> A.most_common(3)
    [(3, 4), (1, 2), (2, 2)]
    
    2
    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    36

    True
    
    6
    True
    
    5

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    0
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    1
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    2

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    0
    True
    
    5

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    5
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    1
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    7

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    8
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    9

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    5
    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    1

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    8
    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    3

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    0
    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    5

    True
    
    6
    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    5

    True
    
    6
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    1 #include<iostream>0

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    0____52 #include<iostream>3#include<iostream>4

    True
    
    6#include<iostream>2 #include<iostream>7#include<iostream>4

    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    5

    True
    
    6
    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    70
    >>> import collections
    
    >>> A = collections.Counter([1, 1, 2, 2, 3, 3, 3, 3, 4, 5, 6, 7])
    >>> A
    Counter({3: 4, 1: 2, 2: 2, 4: 1, 5: 1, 6: 1, 7: 1})
    >>> A.most_common(1)
    [(3, 4)]
    >>> A.most_common(3)
    [(3, 4), (1, 2), (2, 2)]
    
    30
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    71
    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    73
    True
    
    51

    True
    
    6
    >>> import collections
    
    >>> A = collections.Counter([1, 1, 2, 2, 3, 3, 3, 3, 4, 5, 6, 7])
    >>> A
    Counter({3: 4, 1: 2, 2: 2, 4: 1, 5: 1, 6: 1, 7: 1})
    >>> A.most_common(1)
    [(3, 4)]
    >>> A.most_common(3)
    [(3, 4), (1, 2), (2, 2)]
    
    2
    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    77

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    0
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    1 namespace4

    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    5
    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    82
    True
    
    67
    Input: n = 15
    Output: false
    Divisors of 15 are 1, 3 and 5. Sum of 
    divisors is 9 which is not equal to 15.
    
    Input: n = 6
    Output: true
    Divisors of 6 are 1, 2 and 3. Sum of 
    divisors is 6.
    71
    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    73
    True
    
    51

    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number
    87

    Output:   
     

    Below are all perfect numbers till 10000
    6 is a perfect number
    28 is a perfect number
    496 is a perfect number
    8128 is a perfect number

    Độ phức tạp về thời gian: O (√n) O(√n)

    Không gian phụ trợ: O (1), vì không có thêm dung lượng nào được lấy. Hãy là một số sự thật thú vị về các số hoàn hảo: & nbsp; 1) Mỗi ​​số hoàn hảo là của Mẫu 2p? ;? muốn chia sẻ thêm thông tin về chủ đề được thảo luận ở trên & NBSP;O(1), since no extra space has been taken.
    Below are some interesting facts about Perfect Numbers: 
    1) Every even perfect number is of the form 2p?1(2p ? 1) where 2p ? 1 is prime. 
    2) It is unknown whether there are any odd perfect numbers.
    References: 
    https://en.wikipedia.org/wiki/Perfect_number
    Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above