# Recursive function as block value

**URL:** <https://talk.observablehq.com/t/recursive-function-as-block-value/734>\
**Category:** Help\
**Created:** [May 9, 2018, 6:33am UTC](https://talk.observablehq.com/t/recursive-function-as-block-value/734 "2018-05-09T06:33:07Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![tom](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/tom/32/2262_2.png) [@tom](https://talk.observablehq.com/u/tom)\
**Post date:** [May 9, 2018, 7:03am UTC](https://talk.observablehq.com/t/recursive-function-as-block-value/734/2 "2018-05-09T07:03:56Z")

</div>

Sure! The simplest way to do this one is:

```auto
function fib(n) {
  if (n == 0) return 0;
  if (n == 1) return 1;
  return fib(n - 1) + fib(n - 2);
}

```

Observable pulls out the name from function declarations (`function ___`) and class declarations (`class___`), so they work without needing an additional `=` - other cells can reference `fib` by name.

---

_[View the full topic](https://talk.observablehq.com/t/recursive-function-as-block-value/734)._
