How to resolve the algorithm Sum of a series step by step in the Logo programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Sum of a series step by step in the Logo programming language
Table of Contents
Problem Statement
Compute the nth term of a series, i.e. the sum of the n first terms of the corresponding sequence.
Informally this value, or its limit when n tends to infinity, is also called the sum of the series, thus the title of this task.
For this task, use:
This approximates the zeta function for S=2, whose exact value is the solution of the Basel problem.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Sum of a series step by step in the Logo programming language
Source code in the logo programming language
to series :fn :a :b
localmake "sigma 0
for [i :a :b] [make "sigma :sigma + invoke :fn :i]
output :sigma
end
to zeta.2 :x
output 1 / (:x * :x)
end
print series "zeta.2 1 1000
make "pi (radarctan 0 1) * 2
print :pi * :pi / 6
You may also check:How to resolve the algorithm Achilles numbers step by step in the J programming language
You may also check:How to resolve the algorithm XML/XPath step by step in the XSLT programming language
You may also check:How to resolve the algorithm Pinstripe/Display step by step in the Nim programming language
You may also check:How to resolve the algorithm Empty program step by step in the D programming language
You may also check:How to resolve the algorithm Include a file step by step in the Nemerle programming language