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: |

What is Telegram?

Telegram’s stand out feature is its encryption scheme that keeps messages and media secure in transit. The scheme is known as MTProto and is based on 256-bit AES encryption, RSA encryption, and Diffie-Hellman key exchange. The result of this complicated and technical-sounding jargon? A messaging service that claims to keep your data safe.Why do we say claims? When dealing with security, you always want to leave room for scrutiny, and a few cryptography experts have criticized the system. Overall, any level of encryption is better than none, but a level of discretion should always be observed with any online connected system, even Telegram.

For some time, Mr. Durov and a few dozen staffers had no fixed headquarters, but rather traveled the world, setting up shop in one city after another, he told the Journal in 2016. The company now has its operational base in Dubai, though it says it doesn’t keep servers there.Mr. Durov maintains a yearslong friendship from his VK days with actor and tech investor Jared Leto, with whom he shares an ascetic lifestyle that eschews meat and alcohol.

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


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