Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F83165818
pi.cc
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Sep 15, 13:23
Size
329 B
Mime Type
text/x-c
Expires
Tue, Sep 17, 13:23 (2 d)
Engine
blob
Format
Raw Data
Handle
20800741
Attached To
R7571 SP4E-TB-TL-FR
pi.cc
View Options
//Computes the series converging towards pi:
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <iomanip>
#include "pi.hh"
double
ComputePi
::
compute
(
unsigned
int
N
)
{
float
sum
=
0
;
for
(
double
k
=
1
;
k
<
N
+
1
;
k
++
){
sum
=
sum
+
1
/
(
k
*
k
);
}
double
pi
=
sqrt
(
6
*
sum
);
return
pi
;
}
Event Timeline
Log In to Comment