Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F72043677
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, Jul 14, 09:47
Size
329 B
Mime Type
text/x-c
Expires
Tue, Jul 16, 09:47 (1 d, 21 h)
Engine
blob
Format
Raw Data
Handle
19022177
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