<jupyter_start><jupyter_text>Cálculo de e<jupyter_code>import math
print(math.e)
%time
e_aprox = 0.
N = 100

for i in range(N):
    e_aprox = e_aprox + 1/math.factorial(i)
print(e_aprox)
print(e_aprox-math.e)
%time
e_aprox = 0.
N = 100

for i in range(N):
    j = N-i-1
    e_aprox = e_aprox + 1/math.factorial(j)
print(e_aprox)
print(e_aprox-math.e)
%time
e_aprox = 1.
N = 100

f = 1
for i in range(1,N):
    f = f*i
    e_aprox = e_aprox + 1/f    
print(e_aprox)
print(e_aprox-math.e)
%time
e_aprox = 1.
N = 100

for i in range(1,N-1):
    j = N-i-1
    e_aprox = e_aprox + 1/math.factorial(j)
print(e_aprox)
def e_aprox_1(N):
    e_aprox = 0.

    for i in range(N):
        e_aprox = e_aprox + 1/math.factorial(i)
    return e_aprox
def e_aprox_2(N):
    e_aprox = 0.

    for i in range(N):
        j = N-i-1
        e_aprox = e_aprox + 1/math.factorial(j)
    return e_aprox
def e_aprox_3(N):
    e_aprox = 1.

    f = 1
    for i in range(1,N):
        f = f*i
        e_aprox = e_aprox + 1/f  
    return e_aprox
%time
for _ in range(100):
    e_aprox_1(1000)
%time
for _ in range(100):
    e_aprox_2(1000)
%time
for _ in range(100):
    e_aprox_3(1000)<jupyter_output>CPU times: user 1 µs, sys: 0 ns, total: 1 µs
Wall time: 2.86 µs
{'fraction_non_alphanumeric': 0.1314516129032258, 'fraction_numerical': 0.054838709677419356, 'mean_word_length': 2.6075581395348837, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '169996', 'license': 'MIT', 'n_tokens_mistral': 698, 'n_tokens_neox': 604, 'n_words': 142, 'path': 'codes/clase_05/e.ipynb', 'repo_name': 'mlares/computacion2020', 'size': '1240'}