Homework #2
Due: 02/05/2025
Write C code that does the following:
1.
By numerically computing the following series
1−
1
3
+
1
5
−
1
7
+
1
9
− … =
π
4
,
approximate π. Take the first 10,000 terms.
Background
Note that the general term,
a
n
, is expressed as
a
n
=
(−1)
n
+1
2
n
− 1
.
2.
Write a C program that computes
10
∑
n
=1
1
n
!
=
1
1!
+
1
2!
+
1
3!
+ …+
1
10!
.
Noting that
n
! =
n
×(
n
−1)!, 1! = 1,
use a function,
int factorial(int n)
, that returns
n
!=1 ×2 ×3 ×…×
n
.
Make sure that you attach example runs showing the results from the computer.
File translated from T
E
X by
T
T
H
, version 4.03.
On 28 Jan 2025, 21:38.