Напишите программу в паскале,что бы Найти сумму членов арифметической прогрессии, если известны первый член,разность и число членов прогрессии.

8 Дек 2021 в 19:41
129 +1
0
Ответы
1

program SumOfArithmeticProgression;

var
firstElement, difference, numberOfElements, sum: integer;
i: integer;

begin
sum := 0;

write('Enter the first element of the arithmetic progression: ');
readln(firstElement);

write('Enter the difference of the arithmetic progression: ');
readln(difference);

write('Enter the number of elements in the arithmetic progression: ');
readln(numberOfElements);

for i := 1 to numberOfElements do
begin
sum := sum + firstElement + (i - 1) * difference;
end;

writeln('The sum of the elements in the arithmetic progression is: ', sum);

end.

16 Апр 2024 в 20:47
Не можешь разобраться в этой теме?
Обратись за помощью к экспертам
Гарантированные бесплатные доработки в течение 1 года
Быстрое выполнение от 2 часов
Проверка работы на плагиат
Поможем написать учебную работу
Прямой эфир