R
R
Roma2015-10-26 00:36:30
Delphi
Roma, 2015-10-26 00:36:30

How to Calculate the approximate value of an infinite sum with an accuracy of e=0.0001?

ac954573199448e4be1d6d3650fffb2d.PNG
How to do it? Help me please!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Fedoryan, 2015-10-26
@k4roma

program endless_sum;
var
  x, i, j: integer;
  y, sum: extended;

function power(x, n: integer): longint;
var
 a, b: integer;
begin
  if (n = 0) then power := 1;
  if (n = 1) then power := x
  else
    begin
     a := x;
     for b := 2 to n do
       a := a * x;
     power := a;
    end;
end;

begin
  i := 1;
  write('input x: ');
  readln(x);
  sum := x;
  y := power(-1, i) * power(x, 2 * i);
  for j := 1 to 2 * i do
    y := y / j;
  while (abs(y) > 0.0001) do
    begin
      sum := sum + y;
      i := i + 1;
      y := power(-1, i) * x;
      for j := 2 to 2 * i do
        y := y * x / j;
    end;
  writeln(sum:5:4);
  readln();
end.

A
amf1k, 2015-10-26
@amf1k

Google search: "calculate the approximate value of pascal" and the first link.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question