This site is supported by donations to The OEIS Foundation.

# Mathematica OEIS Package

When you go on computing: if you are doing repetitive and boring things, is because you are not working in a proper way. So I decided to write some code to help myself with the worst part of my projects. And as this code began to grow and became more complex, thought it would be good idea to gather all together in the same Mathematica Package and to share it on the internet.

This code includes functions that can make your life easier if you a using the information from OEIS in your archives: for citation in documents or blogs, for programming sequences, or for many other purposes.

## Package Description:

• Version:
• V 1.0, 26 August 2010, Testing...
• V 2.0, 28 November 2010, Old links are no longer valid.

• Changes:
• 29/Aug/2010 - Added OEISbFile function and exporting to HTML
• 28/Nov/2010 - Code rebuilt due to changes in OEIS, old links are no longer valid.
• 04/Jun/2011 - Fixed Unicode LF, instead of Window's CRLF for bFiles.
• 25/Jan/2015 - Repository created at GitHub
• Functions:
• OEISTotalNumberOfSequences
• OEISValidateIDQ
• OEISImport
• OEISURL
• OEISFunction
• OEISExport
• OEISbFile

```<<OEIS`
```

## PROGRAMMING EXAMPLES

### IMPORTING DATA FROM OEIS:

#### Importing Sequence Description:

```In:= OEISImport["A014321","Description"]
Out= The next new gap between successive odd primes (divided by 2).
```

#### Importing Sequence Data:

``` In:= OEISImport["A080321","Data"]
Out= {{0,0},{1,4},{2,428},{3,58747},{4,1758473969},{5,340760636747},{6,14410746502617904},{7,673020037180959760871},
{8,1736622037158911219053381734718},{9,400539731185759177060380684246324}}
```

#### Importing Sequence creation date:

```In:= OEISImport["A117321","Date"]
Out= {Mar,07,2006}
```

#### Importing Sequence Author:

```In:= OEISImport["A014321","Author"]
Out= {Hynek Mlcousek}
```

#### Importing Image:

```In:= OEISImport["A030337","Image"]
Out=
```

#### Importing bFile:

```In:=ListPlot[OEISImport["A094358","bFile"],Joined->True]
Out= (Plot Image)
```

#### Importing Range of Available data:

```In:= OEISImport["A094358","MinData"]
Out= 1
In:= OEISImport["A094358","MaxData"]
Out= 1314
```

### EXPORTING DATA FROM OEIS:

• Exporting Formats:
OEIS.m exporting formats
File Extension Exported data:
*.gp Code to add help for PARI/GP functions
*.m Code to add help for Mathematica
*.txt, *.xls, *.csv, *.tsv, *.dat Data files with sequence values.
*.jpg, *.jpeg, *.jp2, *.j2k, *.bmp, *.pgn, *.gif, *.tiff, *.tif Image plot
*.bib BibTeX citation to OEIS Sequences
*.htm, *.html HTML citation to OEIS Sequences

#### Exporting BibTeX citation:

The input for the function can be a String or a List of Strings:

```In:=OEISExport[{"A026588", "A111084"}, "example.bib"]
Out=example.bib

```

Content of file: example.bib

```@MISC{oeisA026588,
AUTHOR={},
TITLE={The {O}n-{L}ine {E}ncyclopedia of {I}nteger {S}equences},
HOWPUBLISHED={\href{http://oeis.org/A026588}{A026588}},
MONTH={},
YEAR={},
NOTE={Duplicate of A026572.}
}

@MISC{oeisA111084,
AUTHOR={N. J. A. Sloane},
TITLE={The {O}n-{L}ine {E}ncyclopedia of {I}nteger {S}equences},
HOWPUBLISHED={\href{http://oeis.org/A111084}{A111084}},
MONTH={Nov},
YEAR={2005},
NOTE={Where records occur in A111267.}
}
```

#### Exporting Help Code for PARI/GP:

```In:= OEISExport[{"A026588","A111084","A131473"},"code_for_PARIGP.gp"]
Out= code_for_PARIGP.gp
```
• Content of file: code_for_PARIGP.gp
```addhelp(A026588,"A026588: Duplicate of A026572.");
addhelp(A111084,"A111084: Where records occur in A111267.");
```

#### Exporting Help Code for Mathematica:

```In:= OEISExport[{"A026588","A111084","A131473"},"code_for_Mathematica.m"]
Out= code_for_Mathematica.m
```
• Content of file: code_for_Mathematica.m
```A026588::usage="A026588[n]: Duplicate of A026572.";
A111084::usage="A111084[n]: Where records occur in A111267.";
A131473::usage="A131473[n]: a(n)=n^6-n.";
```

#### Exporting all available data

• Example with EXCEL:
```In:= OEISExport[{"A026588","A111084","A131473"},"data.xls"]
Out= {A026588_data.xls,A111084_data.xls,A131473_data.xls}
```

#### Exporting citation to HTML code

```In:=OEISExport[{"A040414", "A050414", "A002323", "A026588"}, "test.html"]
Out= test.html
```
• Content of file: test.html
```<a name="oeisA040414">-</a> N. J. A. Sloane, The On-Line Encyclopedia of Integer Sequences.
<a href=http://oeis.org/A040414">A040414</a>: Continued fraction for sqrt(435).

<a name="oeisA050414">-</a> Jud McCranie, The On-Line Encyclopedia of Integer Sequences.
<a href=http://oeis.org/A050414">A050414</a>: Numbers n such that 2^n - 3 is prime.

<a name="oeisA002323">-</a> N. J. A. Sloane, The On-Line Encyclopedia of Integer Sequences.
<a href=http://oeis.org/A002323">A002323</a>: Fermat remainders.

<a name="oeisA026588">-</a> The On-Line Encyclopedia of Integer Sequences.
<a href=http://oeis.org/A026588">A026588</a>:  Duplicate of A026572.
```

#### Exporting citation to Wiki code

```In:=OEISExport[{"A026518", "A111284"}, "example.wiki"]
Out:=example.wiki
```
• Content of file: example.wiki
```* A026518: a(n) = length of n-th run of identical symbols in A026517.
* A111284: Number of permutations avoiding the patterns {2143,2341,2413,2431,3142,3241,3412,3421,4123,4213,4231,4321,4132,4312};
number of strong sorting class based on 2143.
```

### FUNCTIONS CREATED AUTOMATICALLY: Function: OEISFunction[ID,Opts]:

The options Opts, are all of them True by default, and they can be modified as:

To skip the addition of help to the function:

```OEISFunction[ID,AddHelp->False]
```

To skip the data from the bFile:

```OEISFunction[ID,bFile->False]
```

To do not print on the screen the information outputed:

```OEISFunction[ID,Output->False]
```
• Example of use:
```In:= OEISFunction["A094358"]
A094358(n): Squarefree products of factors of Fermat numbers (A023394).
Data available: Table of n, A094358(n) for n=1..1314
```

From now on, we can use the function with all data already loaded on it:

```In:= A094358
Out= 2917004348489729
```

### GENERATING b-Files:

Function: OEISbFile[ID,Vmax,filename]

• Example:

We can define the function first, but if we do not define it, the code creates the function and preloads all available data from OEIS:

```In:=A040414:=20;
A040414[n_]:=Part[{1,5,1,40},1+Mod[n-1,4}};

In:=OEISbFile["A040414", 200]
Out=b040414.txt
```