
Напишите программу, которая в последовательности натуральных чисел определяет
минимальное число, кратное 5. Программа получает на вход количество чисел в последовательности, а затем сами числа. В последовательности всегда имеется число, кратное 5. Количество чисел не превышает 1000. Введённые числа не превышают 30 000. Программа должна вывести одно число — минимальное число, кратное 5.

Ответы на вопрос

var k,i,min,a: integer;
begin
readln(k);
min:=30000;
for i:=1 to k do
begin
readln(a);
if (a mod 5=0) and (a<min) then min:=a;
end;
writeln(min);
end.



Answer in detail. Write a program that determines the minimum number that is divisible by 5 in a sequence of natural numbers. The program receives the number of numbers in the sequence as input, and then the numbers themselves. There is always a number divisible by 5 in the sequence. The number of numbers does not exceed 1000. The entered numbers do not exceed 30,000. The program should output one number - the minimum number that is divisible by 5.
Here is a possible solution in Python:
```python # Read the number of numbers in the sequence n = int(input())
# Initialize the minimum number divisible by 5 as a large value min_div_5 = 30001
# Loop through the sequence for i in range(n): # Read the next number num = int(input()) # Check if it is divisible by 5 and smaller than the current minimum if num % 5 == 0 and num < min_div_5: # Update the minimum min_div_5 = num
# Print the minimum number divisible by 5 print(min_div_5) ```
This program uses a loop to iterate through the sequence of numbers and keeps track of the smallest number that is divisible by 5. It uses the modulo operator (%) to check if a number is divisible by 5. It prints the final result after the loop ends.


Топ вопросов за вчера в категории Информатика
Последние заданные вопросы в категории Информатика
-
Математика
-
Литература
-
Алгебра
-
Русский язык
-
Геометрия
-
Английский язык
-
Химия
-
Физика
-
Биология
-
Другие предметы
-
История
-
Обществознание
-
Окружающий мир
-
География
-
Українська мова
-
Информатика
-
Українська література
-
Қазақ тiлi
-
Экономика
-
Музыка
-
Право
-
Беларуская мова
-
Французский язык
-
Немецкий язык
-
МХК
-
ОБЖ
-
Психология
-
Физкультура и спорт
-
Астрономия
-
Кыргыз тили
-
Оʻzbek tili