Bacancy Technology
Bacancy Technology represents the connected world, offering innovative and customer-centric information technology experiences, enabling Enterprises, Associates and the Society to Rise™.
12+
Countries where we have happy customers
1050+
Agile enabled employees
06
World wide offices
12+
Years of Experience
05
Agile Coaches
14
Certified Scrum Masters
1000+
Clients projects
1458
Happy customers
Artificial Intelligence
Machine Learning
Salesforce
Microsoft
SAP
November 21, 2023
It seems like you’re trying to plot the time taken to compute the factorial of each number from 1 to 150. However, there are a few issues with your code:
import numpy as np import time import math import matplotlib.pyplot as plt n = np.arange(1, 151) dt = np.zeros_like(n, dtype=float) for i in range(150): start_time = time.time() math.factorial(i+1) # replace np.math.factorial with math.factorial dt[i] = (time.time() - start_time) plt.plot(n, dt) plt.xlabel('Number') plt.ylabel('Time taken (s)') plt.title('Time taken to compute factorial') plt.show()