Telegram Group & Telegram Channel
🎓 Задача по Python #46

Описание:

Напишите программу, которая проверит, что число является совершенным.
Совершенное число - натуральное число, равное сумме всех своих собственных делителей.
Например, число 6 равно сумме своих собственных делителей 1 + 2 + 3.

Примеры совершенных чисел:

6, 28, 496, 8128

Решение:

def get_divisors(num):
divisors = []
for i in range(1, num):
if num % i == 0:
divisors.append(i)
return divisors

def perfect_num(num):
divisors = get_divisors(num)
return num == sum(divisors)

print(perfect_num(6))
print(perfect_num(28))
print(perfect_num(496))
print(perfect_num(8128))

Свой вариант решения в комментарии 💬

#задачи



tg-me.com/pythonturboru/559
Create:
Last Update:

🎓 Задача по Python #46

Описание:

Напишите программу, которая проверит, что число является совершенным.
Совершенное число - натуральное число, равное сумме всех своих собственных делителей.
Например, число 6 равно сумме своих собственных делителей 1 + 2 + 3.

Примеры совершенных чисел:

6, 28, 496, 8128

Решение:

def get_divisors(num):
divisors = []
for i in range(1, num):
if num % i == 0:
divisors.append(i)
return divisors

def perfect_num(num):
divisors = get_divisors(num)
return num == sum(divisors)

print(perfect_num(6))
print(perfect_num(28))
print(perfect_num(496))
print(perfect_num(8128))

Свой вариант решения в комментарии 💬

#задачи

BY Python Turbo. Уютное сообщество Python разработчиков.




Share with your friend now:
tg-me.com/pythonturboru/559

View MORE
Open in Telegram


Python Turbo Уютное сообщество Python разработчиков Telegram | DID YOU KNOW?

Date: |

A Telegram spokesman declined to comment on the bond issue or the amount of the debt the company has due. The spokesman said Telegram’s equipment and bandwidth costs are growing because it has consistently posted more than 40% year-to-year growth in users.

What is Secret Chats of Telegram

Secret Chats are one of the service’s additional security features; it allows messages to be sent with client-to-client encryption. This setup means that, unlike regular messages, these secret messages can only be accessed from the device’s that initiated and accepted the chat. Additionally, Telegram notes that secret chats leave no trace on the company’s services and offer a self-destruct timer.

Python Turbo Уютное сообщество Python разработчиков from id


Telegram Python Turbo. Уютное сообщество Python разработчиков.
FROM USA