# 項から数列の式を求める（find_sequence_function）

最初の項から数列の一般項を求めます。さらに2項を予測できる場合にのみ返します。

## 書き方

### find_sequence_function(terms, variable)

各項を与える a(n) の式と、それに続く項。1項足りない場合は手がかりとして規則を示します。

**terms**

最初のいくつかの項。整数または分数で、先頭が a(1)。リストを受け取ります。

**variable**

式の添字。n などの名前。変数または変数のリストを受け取ります。

## 例題

- $\displaystyle 1, 4, 9, 16, 25, \ldots \Rightarrow n^{2}$

  `find_sequence_function([1, 4, 9, 16, 25], n)`

  ソルバーでは、`find_sequence_function([1, 4, 9, 16, 25], n)` の答えは `n^2` です。

  [ソルバーで開く](https://ja.hilberon.com/?q=find_sequence_function%28%5B1%2C%204%2C%209%2C%2016%2C%2025%5D%2C%20n%29)
- $\displaystyle 1, 1, 2, 3, 5, 8, 13, 21, \ldots \Rightarrow \operatorname{fibonacci}(n)$

  `find_sequence_function([1, 1, 2, 3, 5, 8, 13, 21], n)`

  ソルバーでは、`find_sequence_function([1, 1, 2, 3, 5, 8, 13, 21], n)` の答えは `fibonacci(n)` です。

  [ソルバーで開く](https://ja.hilberon.com/?q=find_sequence_function%28%5B1%2C%201%2C%202%2C%203%2C%205%2C%208%2C%2013%2C%2021%5D%2C%20n%29)
- $\displaystyle 1, 2, 6, 24, 120, \ldots \Rightarrow n!$

  `find_sequence_function([1, 2, 6, 24, 120], n)`

  ソルバーでは、`find_sequence_function([1, 2, 6, 24, 120], n)` の答えは `n!` です。

  [ソルバーで開く](https://ja.hilberon.com/?q=find_sequence_function%28%5B1%2C%202%2C%206%2C%2024%2C%20120%5D%2C%20n%29)
- $\displaystyle 2, 3, 5, 5, 8, 7, \ldots \Rightarrow \begin{cases} \frac{3 n+1}{2} & \text{if } n \bmod 2 = 1 \\ n+1 & \text{otherwise} \end{cases}$

  `find_sequence_function([2, 3, 5, 5, 8, 7], n)`

  ソルバーでは、`find_sequence_function([2, 3, 5, 5, 8, 7], n)` の答えは `piecewise((3n + 1)/2 if n % 2 = 1, n + 1 otherwise)` です。

  [ソルバーで開く](https://ja.hilberon.com/?q=find_sequence_function%28%5B2%2C%203%2C%205%2C%205%2C%208%2C%207%5D%2C%20n%29)
- $\displaystyle 3, 8, 17, 32, 57, 100, 177, \ldots \Rightarrow n^{2}+2^{n}$

  `find_sequence_function([3, 8, 17, 32, 57, 100, 177], n)`

  ソルバーでは、`find_sequence_function([3, 8, 17, 32, 57, 100, 177], n)` の答えは `n^2 + 2^n` です。

  [ソルバーで開く](https://ja.hilberon.com/?q=find_sequence_function%28%5B3%2C%208%2C%2017%2C%2032%2C%2057%2C%20100%2C%20177%5D%2C%20n%29)

## 関連する関数

- [find_linear_recurrence](https://ja.hilberon.com/library/find_linear_recurrence)

  項の列が従う漸化式。さらに2項でも成り立つ場合にのみ返します。
- [next_terms](https://ja.hilberon.com/library/next_terms)

  リストに続く項。規則がそれを説明し、さらに二つを予測できる場合にのみ与えられます。
- [numeric_product](https://ja.hilberon.com/library/numeric_product)

  範囲にわたって式を掛け合わせ、小数で求めます。
- [differences](https://ja.hilberon.com/library/differences)

  リストの隣り合う要素の差。
- [numeric_sum](https://ja.hilberon.com/library/numeric_sum)

  範囲にわたって式を足し合わせ、小数で求めます。
- [sum_convergence](https://ja.hilberon.com/library/sum_convergence)

  変数についての式の和が収束するかどうかを判定します。

---
Source: https://ja.hilberon.com/library/find_sequence_function
