Fetch OEIS Sequences
May 21, 2019
I needed to fetch several sequences from the OEIS the other day. We’ve done that in a previous exercise, in Scheme, but I wanted something I could run from the command line. So I wrote a program.
Your task is to write a program, called from a normal shell command line, that fetches a sequence from OEIS. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.
Since OEIS offers a nice JSON format, I thought I’d take advantage:
get_seq adds the ‘id:’ prefix to the search term, so only one sequence is fetched. Next step is to add command line switches to control that behaviour, so multiple sequences can be fetched at once.
Here’s a solution in Python.
Example Usage: