Надо сделать на Python!
1. Дан массив из 25 элементов. Правда ли, что максимальный элемент не кратен 7?
2. Дан массив из 25 элементов.
Найти произведение элементов,
которые делятся на 5 или 11 и не делятся на 6 и 7.
Даю 25 баллов.
Надо сделать на Python!
Ответы на вопрос
первый код
arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]
# Check if the maximum element is a multiple of 7
if max(arr) % 7 == 0:
print("The maximum element is a multiple of 7")
else:
print("The maximum element is not a multiple of 7")
второй код
# Define an array of 25 elements
arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]
# Initialize the product to 1
product = 1
# Iterate over the elements in the array
for num in arr:
# Check if the element is divisible by 5 or 11 and not divisible by 6 and 7
if (num % 5 == 0 or num % 11 == 0) and num % 6 != 0 and num % 7 != 0:
# Multiply the element by the current product
product *= num
# Print the product
print(product)