Created
October 17, 2022 01:04
-
-
Save galenseilis/7360b1e57021afeb87575599e2ac016e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import networkx as nx | |
| import matplotlib.pyplot as plt | |
| from sympy import factorint | |
| def f(n): | |
| result = factorint(n) | |
| result = result.items() | |
| result = [n*e//p for p, e in result] | |
| result = sum(result) | |
| result = result if n > 1 else 0 | |
| return result | |
| g = nx.DiGraph() | |
| results = [] | |
| for i in range(1, 1000001): | |
| g.add_edge(i, f(i)) | |
| leafs = [i for i in g.nodes() if not list(g.successors(i))] | |
| percent_leaf = len(leafs) / len(g.nodes()) * 100 | |
| results.append(percent_leaf) | |
| print(i, percent_leaf) | |
| plt.plot(results) | |
| plt.show() | |
| ##C = nx.condensation(g) | |
| ##nx.draw(C, node_size=1) | |
| ##plt.savefig('condensation_arithmetic_derivatives.pdf') | |
| ##plt.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment