How to verify Eulers Theory

1 view (last 30 days)
Chris on 10 Jun 2013
The mathematician Euler proved the following:
pi^2/6= 1+1/4+1/9+1/16 ...
Rather than finding a mathematical proof for this, verify whether the conjecture seems to be true or not by writing a loop until the sum is close to pi^2/6
I have trouble understanding loops. help please!

Accepted Answer

Julius on 10 Jun 2013
sum = 0;
threshold = 1e-6;
for ii = 1 : 1 : 100000
sum = sum + 1/ii^2;
if abs(sum - pi^2/6) <= threshold
disp(sprintf('%s iterations needed to approach pi^2/6',num2str(ii)));
Walter Roberson
Walter Roberson on 10 Jun 2013
Providing complete homework solutions is not advised.

Sign in to comment.

More Answers (0)


Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!