chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
def factorial():
|
||||
f, n = 1, 1
|
||||
while True: # First iteration:
|
||||
yield f # yield 1 to start with and then
|
||||
f, n = f * n, n+1 # f will now be 1, and n will be 2, ...
|
||||
|
||||
for index, factorial_number in zip(range(51), factorial()):
|
||||
print('{i:3}!= {f:65}'.format(i=index, f=factorial_number))
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
def fib():
|
||||
a, b = 0, 1
|
||||
while True: # First iteration:
|
||||
yield a # yield 0 to start with and then
|
||||
a, b = b, a + b # a will now be 1, and b will also be 1, (0 + 1)
|
||||
|
||||
for index, fibonacci_number in zip(range(100), fib()):
|
||||
print('{i:3}: {f:3}'.format(i=index, f=fibonacci_number))
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
from decimal import Decimal, getcontext
|
||||
getcontext().prec=60
|
||||
summation = 0
|
||||
for k in range(50):
|
||||
summation = summation + 1/Decimal(16)**k * (
|
||||
Decimal(4)/(8*k+1)
|
||||
- Decimal(2)/(8*k+4)
|
||||
- Decimal(1)/(8*k+5)
|
||||
- Decimal(1)/(8*k+6)
|
||||
)
|
||||
print(summation)
|
||||
|
||||
Reference in New Issue
Block a user