Skip to content

Commit 9f322fd

Browse files
committed
Complejidad Algoritmica
1 parent 7414dd3 commit 9f322fd

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import time
2+
import sys
3+
4+
def factorial(n):
5+
response = 1
6+
7+
while n > 1:
8+
response = response * n
9+
n = n - 1
10+
11+
return response
12+
13+
14+
def factorial_recursive(n):
15+
if n == 1:
16+
return 1
17+
18+
return n * factorial_recursive(n - 1)
19+
20+
21+
if __name__ == '__main__':
22+
n = 2500
23+
sys.setrecursionlimit(n + 10)
24+
25+
startingTime = time.time()
26+
factorial(n)
27+
endTime = time.time()
28+
print(f"Execturion time with bucle\t{endTime - startingTime}");
29+
30+
startingTime = time.time()
31+
factorial_recursive(n)
32+
endTime = time.time()
33+
print(f"Execution time with recusive\t{endTime - startingTime}");

Desarrollo/18_GraficadoSimple.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from bokeh.plotting import figure, output_file, show
2+
3+
if __name__ == '__main__':
4+
output_file('graficado_simple.html')
5+
fig = figure()
6+
7+
total_vals = int(input('Cuantos valores quieres graficar?'))
8+
x_vals = list(range(total_vals))
9+
y_vals = []
10+
11+
for x in x_vals:
12+
val = int(input(f'Valor y para {x}'))
13+
y_vals.append(val)
14+
15+
fig.line(x_vals, y_vals, line_width=2)
16+
show(fig)

0 commit comments

Comments
 (0)