# Series


```python
import pandas as pd
from oeis.sequence import OEIS_Sequence
from matplotlib import pyplot as plt
```


```python
plt.plot(Sequence.terms)
plt.title(Sequence.description)
plt.show()
```


```python
def formula_latex(k, floor=True):
    latex = r"$$\left\lfloor\frac{n^2}{" + str(k) + r"}\right\rfloor$$"
    if not floor:
        latex = latex.replace("floor", "ceil") 
    return latex
```


```python
def oeis_md_link(id_):
    return f'[{id_}]({OEIS_URL}{id_})'
```


```python
SEQ_LIST = ['A000290', 'A007590', 'A000212',
            'A002620', 'A118015', 'A056827',
            'A056834', 'A130519', 'A056838',
            'A056865']
```


```python
series_table = pd.DataFrame(columns= ['k',
                             'Secuencia',
                             'Fórmula',
                             'Descripción',
                             'Términos'])
MAX_TERMS = 15


for num, id_ in enumerate(SEQ_LIST):
    Seq = OEIS_Sequence(id_)
    series_table = series_table.append({'k': num + 1,
                                        'Secuencia': oeis_md_link(id_),
                                        'Fórmula': formula_latex(num + 1),
                                        'Descripción': Seq.description,
                                        'Términos': Seq.terms[:MAX_TERMS]
                                       }, ignore_index=True)
```


```python
series_table
```




<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }

    .dataframe tbody tr th {
        vertical-align: top;
    }

    .dataframe thead th {
        text-align: right;
    }
</style>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>k</th>
      <th>Secuencia</th>
      <th>Fórmula</th>
      <th>Descripción</th>
      <th>Términos</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>1</td>
      <td>[A000290](http://oeis.org/A000290)</td>
      <td>$$\left\lfloor\frac{n^2}{1}\right\rfloor$$</td>
      <td>The squares: a(n) = n^2.</td>
      <td>[0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121,...</td>
    </tr>
    <tr>
      <th>1</th>
      <td>2</td>
      <td>[A007590](http://oeis.org/A007590)</td>
      <td>$$\left\lfloor\frac{n^2}{2}\right\rfloor$$</td>
      <td>a(n) = floor(n^2/2).</td>
      <td>[0, 0, 2, 4, 8, 12, 18, 24, 32, 40, 50, 60, 72...</td>
    </tr>
    <tr>
      <th>2</th>
      <td>3</td>
      <td>[A000212](http://oeis.org/A000212)</td>
      <td>$$\left\lfloor\frac{n^2}{3}\right\rfloor$$</td>
      <td>a(n) = floor(n^2/3).</td>
      <td>[0, 0, 1, 3, 5, 8, 12, 16, 21, 27, 33, 40, 48,...</td>
    </tr>
    <tr>
      <th>3</th>
      <td>4</td>
      <td>[A002620](http://oeis.org/A002620)</td>
      <td>$$\left\lfloor\frac{n^2}{4}\right\rfloor$$</td>
      <td>Quarter-squares: floor(n/2)*ceiling(n/2). Equi...</td>
      <td>[0, 0, 1, 2, 4, 6, 9, 12, 16, 20, 25, 30, 36, ...</td>
    </tr>
    <tr>
      <th>4</th>
      <td>5</td>
      <td>[A118015](http://oeis.org/A118015)</td>
      <td>$$\left\lfloor\frac{n^2}{5}\right\rfloor$$</td>
      <td>a(n) = floor(n^2/5).</td>
      <td>[0, 0, 0, 1, 3, 5, 7, 9, 12, 16, 20, 24, 28, 3...</td>
    </tr>
    <tr>
      <th>5</th>
      <td>6</td>
      <td>[A056827](http://oeis.org/A056827)</td>
      <td>$$\left\lfloor\frac{n^2}{6}\right\rfloor$$</td>
      <td>a(n) = floor(n^2/6).</td>
      <td>[0, 0, 0, 1, 2, 4, 6, 8, 10, 13, 16, 20, 24, 2...</td>
    </tr>
    <tr>
      <th>6</th>
      <td>7</td>
      <td>[A056834](http://oeis.org/A056834)</td>
      <td>$$\left\lfloor\frac{n^2}{7}\right\rfloor$$</td>
      <td>a(n) = floor(n^2/7).</td>
      <td>[0, 0, 0, 1, 2, 3, 5, 7, 9, 11, 14, 17, 20, 24...</td>
    </tr>
    <tr>
      <th>7</th>
      <td>8</td>
      <td>[A130519](http://oeis.org/A130519)</td>
      <td>$$\left\lfloor\frac{n^2}{8}\right\rfloor$$</td>
      <td>a(n) = Sum_{k=0..n} floor(k/4). (Partial sums ...</td>
      <td>[0, 0, 0, 0, 1, 2, 3, 4, 6, 8, 10, 12, 15, 18,...</td>
    </tr>
    <tr>
      <th>8</th>
      <td>9</td>
      <td>[A056838](http://oeis.org/A056838)</td>
      <td>$$\left\lfloor\frac{n^2}{9}\right\rfloor$$</td>
      <td>a(n) = floor(n^2/9).</td>
      <td>[0, 0, 0, 1, 1, 2, 4, 5, 7, 9, 11, 13, 16, 18,...</td>
    </tr>
    <tr>
      <th>9</th>
      <td>10</td>
      <td>[A056865](http://oeis.org/A056865)</td>
      <td>$$\left\lfloor\frac{n^2}{10}\right\rfloor$$</td>
      <td>a(n) = floor(n^2/10).</td>
      <td>[0, 0, 0, 0, 1, 2, 3, 4, 6, 8, 10, 12, 14, 16,...</td>
    </tr>
  </tbody>
</table>
</div>




```python
# Tabla en markdown para incluir en el capítulo
print(series_table.to_markdown(index=False))
```

    |   k | Secuencia                          | Fórmula                                     | Descripción                                                           | Términos                                                      |
    |----:|:-----------------------------------|:--------------------------------------------|:----------------------------------------------------------------------|:--------------------------------------------------------------|
    |   1 | [A000290](http://oeis.org/A000290) | $$\left\lfloor\frac{n^2}{1}\right\rfloor$$  | The squares: a(n) = n^2.                                              | [0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196] |
    |   2 | [A007590](http://oeis.org/A007590) | $$\left\lfloor\frac{n^2}{2}\right\rfloor$$  | a(n) = floor(n^2/2).                                                  | [0, 0, 2, 4, 8, 12, 18, 24, 32, 40, 50, 60, 72, 84, 98]       |
    |   3 | [A000212](http://oeis.org/A000212) | $$\left\lfloor\frac{n^2}{3}\right\rfloor$$  | a(n) = floor(n^2/3).                                                  | [0, 0, 1, 3, 5, 8, 12, 16, 21, 27, 33, 40, 48, 56, 65]        |
    |   4 | [A002620](http://oeis.org/A002620) | $$\left\lfloor\frac{n^2}{4}\right\rfloor$$  | Quarter-squares: floor(n/2)*ceiling(n/2). Equivalently, floor(n^2/4). | [0, 0, 1, 2, 4, 6, 9, 12, 16, 20, 25, 30, 36, 42, 49]         |
    |   5 | [A118015](http://oeis.org/A118015) | $$\left\lfloor\frac{n^2}{5}\right\rfloor$$  | a(n) = floor(n^2/5).                                                  | [0, 0, 0, 1, 3, 5, 7, 9, 12, 16, 20, 24, 28, 33, 39]          |
    |   6 | [A056827](http://oeis.org/A056827) | $$\left\lfloor\frac{n^2}{6}\right\rfloor$$  | a(n) = floor(n^2/6).                                                  | [0, 0, 0, 1, 2, 4, 6, 8, 10, 13, 16, 20, 24, 28, 32]          |
    |   7 | [A056834](http://oeis.org/A056834) | $$\left\lfloor\frac{n^2}{7}\right\rfloor$$  | a(n) = floor(n^2/7).                                                  | [0, 0, 0, 1, 2, 3, 5, 7, 9, 11, 14, 17, 20, 24, 28]           |
    |   8 | [A130519](http://oeis.org/A130519) | $$\left\lfloor\frac{n^2}{8}\right\rfloor$$  | a(n) = Sum_{k=0..n} floor(k/4). (Partial sums of A002265.)            | [0, 0, 0, 0, 1, 2, 3, 4, 6, 8, 10, 12, 15, 18, 21]            |
    |   9 | [A056838](http://oeis.org/A056838) | $$\left\lfloor\frac{n^2}{9}\right\rfloor$$  | a(n) = floor(n^2/9).                                                  | [0, 0, 0, 1, 1, 2, 4, 5, 7, 9, 11, 13, 16, 18, 21]            |
    |  10 | [A056865](http://oeis.org/A056865) | $$\left\lfloor\frac{n^2}{10}\right\rfloor$$ | a(n) = floor(n^2/10).                                                 | [0, 0, 0, 0, 1, 2, 3, 4, 6, 8, 10, 12, 14, 16, 19]            |



```python
for k, seq in enumerate(SEQ_LIST):
    lst = SEQ_LIST.copy()
    del lst[k]
    print(k, seq, lst)
```

    0 A000290 ['A007590', 'A000212', 'A002620', 'A118015', 'A056827', 'A056834', 'A130519', 'A056838', 'A056865']
    1 A007590 ['A000290', 'A000212', 'A002620', 'A118015', 'A056827', 'A056834', 'A130519', 'A056838', 'A056865']
    2 A000212 ['A000290', 'A007590', 'A002620', 'A118015', 'A056827', 'A056834', 'A130519', 'A056838', 'A056865']
    3 A002620 ['A000290', 'A007590', 'A000212', 'A118015', 'A056827', 'A056834', 'A130519', 'A056838', 'A056865']
    4 A118015 ['A000290', 'A007590', 'A000212', 'A002620', 'A056827', 'A056834', 'A130519', 'A056838', 'A056865']
    5 A056827 ['A000290', 'A007590', 'A000212', 'A002620', 'A118015', 'A056834', 'A130519', 'A056838', 'A056865']
    6 A056834 ['A000290', 'A007590', 'A000212', 'A002620', 'A118015', 'A056827', 'A130519', 'A056838', 'A056865']
    7 A130519 ['A000290', 'A007590', 'A000212', 'A002620', 'A118015', 'A056827', 'A056834', 'A056838', 'A056865']
    8 A056838 ['A000290', 'A007590', 'A000212', 'A002620', 'A118015', 'A056827', 'A056834', 'A130519', 'A056865']
    9 A056865 ['A000290', 'A007590', 'A000212', 'A002620', 'A118015', 'A056827', 'A056834', 'A130519', 'A056838']



```python
V = ['A000290', 'A007590', 'A000212', 'A002620', 'A118015', 'A056827', 'A056834', 'A130519', 'A056865']
```


```python
txt = ""

for x in V:
    txt = txt + ", " + x
txt
```




    ', A000290, A007590, A000212, A002620, A118015, A056827, A056834, A130519, A056865'




```python
from math import floor

def f(n, k):
    return floor((n ** 2) / k)
```


```python
lst = []
acc = 0
for n in range(20):
    acc += f(n, 2) 
    lst.append(acc)
```


```python
print(lst)
```

    [0, 0, 2, 6, 14, 26, 44, 68, 100, 140, 190, 250, 322, 406, 504, 616, 744, 888, 1050, 1230]



```python
lista = []

for n in range(20):
    lista.append(floor((2 * (n ** 3) + 3 * (n ** 2) - 2 * n)/12))
```


```python
print(lista)
```

    [0, 0, 2, 6, 14, 26, 44, 68, 100, 140, 190, 250, 322, 406, 504, 616, 744, 888, 1050, 1230]



```python
from sympy import Sum, symbols, simplify
```


```python
i, k, n = symbols('i k n', integer=True)
simplify(Sum((i ** 2) / k , (i, 1, n)).doit())
```




$\displaystyle \frac{n \left(2 n^{2} + 3 n + 1\right)}{6 k}$




```python

```

d3f4991d356c73a7439e08e3a39cd9062f7e5544
ipynb
Jupyter Notebook
code/01-Intro/oeis.ipynb
EnriquePH/Libro_Bestiario_Mates
77347cbf5fd9e4c6f7d52c671e29c8d6781b0bb7
CC0-1.0
code/01-Intro/oeis.ipynb
EnriquePH/Libro_Bestiario_Mates
77347cbf5fd9e4c6f7d52c671e29c8d6781b0bb7
CC0-1.0
code/01-Intro/oeis.ipynb
EnriquePH/Libro_Bestiario_Mates
77347cbf5fd9e4c6f7d52c671e29c8d6781b0bb7
CC0-1.0
Qwen/Qwen-72B
1. YES
2. YES