Created
July 26, 2023 17:41
-
-
Save cshjin/7ea0ac31c39c750cd95319ac7e1f1e03 to your computer and use it in GitHub Desktop.
OEIS - A360497
This file contains 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
# OEIS sequence id A360497: https://oeis.org/A360497 | |
# | |
# Author: Hongwei Jin <[email protected]> | |
# Date: 2023-07-26 | |
from sympy import isprime | |
import matplotlib.pyplot as plt | |
import networkx as nx | |
seq = [2, 3, 5, 7] | |
for i in range(9, 10**6, 2): | |
s = str(i) | |
if set(s) <= set("2357") and sum(map(int, s)) in seq and isprime(i): | |
seq.append(i) | |
print(seq) | |
# plot the sequence | |
fig = plt.figure(figsize=(4,4), tight_layout=True) | |
plt.plot(seq) | |
# plot the sequence as a directed acyclic graph | |
fig = plt.figure(figsize=(4,4), tight_layout=True) | |
nodes = seq | |
edges = [(i, sum(int(digit) for digit in str(i))) for i in seq] | |
DiG = nx.DiGraph(edges) | |
pos = nx.circular_layout(DiG) | |
nx.draw_networkx(DiG, pos, with_labels=False, node_size=20) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sequence plot in the first 175 numbers
A DAG plot of the sequence above