File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -3732,8 +3732,8 @@ In order to achieve greater coverage and encourage more people to contribute to
3732
3732
</a>
3733
3733
</td>
3734
3734
<td> <!-- C++ -->
3735
- <a href="./CONTRIBUTING.md ">
3736
- <img align="center" height="25" src="./logos/github .svg" />
3735
+ <a href="src/cpp/LeibnizFormulaForPi.cpp ">
3736
+ <img align="center" height="25" src="./logos/cplusplus .svg" />
3737
3737
</a>
3738
3738
</td>
3739
3739
<td> <!-- Java -->
Original file line number Diff line number Diff line change
1
+ #include < iostream>
2
+ using namespace std ;
3
+
4
+ float pi = 0.0 ;
5
+ float denominator = 1.0 ;
6
+ float operation = 1.0 ;
7
+
8
+ float pi_calculator (int terms)
9
+ {
10
+ for (int i = 0 ; i < terms; i++)
11
+ {
12
+ pi += operation * (4.0 / denominator);
13
+ denominator += 2.0 ;
14
+ operation *= -1.0 ;
15
+ }
16
+ return pi;
17
+ }
18
+
19
+ int main ()
20
+ {
21
+ float result = pi_calculator (100000 );
22
+ cout << result;
23
+ }
You can’t perform that action at this time.
0 commit comments