Skip to content

Instantly share code, notes, and snippets.

@cshjin
Created July 26, 2023 17:41
Show Gist options
  • Save cshjin/7ea0ac31c39c750cd95319ac7e1f1e03 to your computer and use it in GitHub Desktop.
Save cshjin/7ea0ac31c39c750cd95319ac7e1f1e03 to your computer and use it in GitHub Desktop.
OEIS - A360497
# 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)
@cshjin
Copy link
Author

cshjin commented Jul 26, 2023

  • Sequence plot in the first 175 numbers
    image

  • A DAG plot of the sequence above
    image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment