# Fibonacci

Barisan Fibonacci merupakan baris yang berawal dari 0 dan 1, kemudian angka berikutnya didapatkan dengan cara menambahkan kedua bilangan yang berurutan sebelumnya. Dengan aturan ini, maka barisan bilangan Fibonacci yang pertama adalah:

> 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377

Deret fibronaci di definisikan dengan fungsi dasar berikut:

```javascript
f(1) = 0
f(2) = 1
f(x) = f(x-1) + f(x-2)
```

implementasidari fungsi di atas akan berbentuk seperti ini:

{% tabs %}
{% tab title="Python" %}

```python
def fib (n:int): 
    if (n == 1) fib = 0
    if (n == 2) fib = 1
    fib = fib(n - 1) + fib(n-2)
```

{% endtab %}

{% tab title="C#" %}

```csharp
int fib(int n){

    if (n == 1) return 0;
    if (n == 2) return 1;

    return fib(n-1) + fib(n-2);
}
```

{% endtab %}

{% tab title="MatLab" %}

```fsharp
 function f = fibonacci(n)
     if (n == 1)
         f = 1;
     else if (n == 2)
         f = 2;
     else
         f = fibonacci(n-1) + fibonacci(n-2);   
 end
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
&#x20;Ini hanya berupa fungsi, jangan lupa di buat di dalam kode. atau lihat halaman berikutnya
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ufarasfa.gitbook.io/coding/tutorial/rekursif-fib.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
