Skip to content

Instantly share code, notes, and snippets.

@Hermann-SW
Created December 31, 2023 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hermann-SW/3112d25ede6052df738d8d96651f6d5d to your computer and use it in GitHub Desktop.
Save Hermann-SW/3112d25ede6052df738d8d96651f6d5d to your computer and use it in GitHub Desktop.
Search integer sequence specified by short PARI/GP script on oeis.org
@Hermann-SW
Copy link
Author

Hermann-SW commented Dec 31, 2023

pi@raspberrypi5:~ $ shellcheck /usr/local/bin/gp_oeis_search 
pi@raspberrypi5:~ $ gp_oeis_search 'for(i=1,40,print1(qfbclassno(-4*i),","))'
pi@raspberrypi5:~ $ 

URL opened in browser:
https://oeis.org/search?q=1,1,1,1,2,2,1,2,2,2,3,2,2,4,2,2,4,2,3,4,4,2,3,4,2,6,3,2,6,4,3,4,4,4,6,4,2,6,4,4,

@Hermann-SW
Copy link
Author

Hermann-SW commented Jan 1, 2024

I work with PARI/GP on my smartphone as well, under Termux app.
I do not know how to open a link on smartphone firefox app from termux.
So I installed termux-x11:
https://ivonblog.com/en-us/posts/termux-x11/

Then I started xfce session per that instruction in background in termux:

termux-x11 :0 -xstartup "dbus-launch --exit-with-session xfce4-session" 2>err &

Then I queried -4*n classnumber sequence as before in termux ...

DISPLAY=:0 ./gp_oeis_search 'for(i=1,40,print1(qfbclassno(-4*i),","))'

... and switched to termux x11 app to see below.

Font is a bit small for my 6.67" smartphone display, but on bigger displays of tablets all is fine.

@Hermann-SW
Copy link
Author

Hermann-SW commented Jan 1, 2024

Jus learned from Karim that all can be done from within PARI/GP as well in this thread:
https://pari.math.u-bordeaux.fr/archives/pari-users-2401/msg00000.html

Final version with suppressing "system()" warnings:

pi@raspberrypi5:~ $ BROWSER=firefox gp -q oeis.gp
? 

Opens this in browser:
https://oeis.org/search?q=1,1,1,2,2,1,2,2,2,3,2,2,4,

oeis.gp:

oeis(v)={
  my(s = ""); for (i=1, #v, s = concat(s, Str(v[i]",")));
  system(Str("$BROWSER https://oeis.org/search?q=";, s, ">/dev/null 2>&1 &"))
}

v = vector(40, i, qfbclassno(-4*i)); /* some sequence of interest */
oeis(v[2..14]);

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