Skip to content

Instantly share code, notes, and snippets.

@Hermann-SW
Last active March 23, 2026 12:14
Show Gist options
  • Select an option

  • Save Hermann-SW/fd11d39ca63bc95879e1949b977ff6f8 to your computer and use it in GitHub Desktop.

Select an option

Save Hermann-SW/fd11d39ca63bc95879e1949b977ff6f8 to your computer and use it in GitHub Desktop.
Combine PARI/GP script Graphviz output for several input values as SVGs into single row HTML table
#!/bin/bash
# gps2svgs psp2.gp 341 561 645 1105 1387 1729 1905 2047 > tst.html
# shell checked
#
scr=$1;shift
echo "<html><body><table border=1><tr>"
for n in "$@"; do echo "<td>$(dot -Tsvg <(n=$n gp -q < "$scr"))</td>"; done
echo "</tr></table></body></html>"
@Hermann-SW
Copy link
Copy Markdown
Author

Hermann-SW commented Mar 22, 2026

Scaled to 25% (firefox) fullpage screenshot of tst.html created with:

gps2svgs psp2.gp 341 561 645 1105 1387 1729 1905 2047 > tst.html
gps2svgs 25pc
$ cat psp2.gp 
\\ generate base 2 Fermat pseudoprime n-1 divisors digraph
n=if(getenv("n"),eval(getenv("n")),172081);
D=divisors(n-1);
P=factorint(n-1)[,1];
M=matrix(#D);
rec(d)={
  x=vecsearch(D,d);
  foreach(P,p,
    y=vecsearch(D,d/p);
    if(d%p==0&&M[x,y]==0,
      print(d"->"d/p"[label=\""p"\"]");M[x,y]=1;rec(d/p)
    );
  );
}
print("digraph D {");
rec(n-1);
print("}");
$

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