Back to Type Challenges

README

questions/04182-medium-fibonacci-sequence/README.md

latest1.4 KB
Original Source
<!--info-header-start--><h1>Fibonacci Sequence </h1><blockquote><p>by windliang <a href="https://github.com/wind-liang" target="_blank">@wind-liang</a></p></blockquote><p><a href="https://tsch.js.org/4182/play" target="_blank"></a> &nbsp;&nbsp;&nbsp;<a href="./README.zh-CN.md" target="_blank"></a> </p><!--info-header-end-->

Implement a generic Fibonacci<T> that takes a number T and returns its corresponding Fibonacci number.

The sequence starts: 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ...

For example

ts
type Result1 = Fibonacci<3> // 2
type Result2 = Fibonacci<8> // 21
<!--info-footer-start-->

<a href="../../README.md" target="_blank"></a> <a href="https://tsch.js.org/4182/answer" target="_blank"></a> <a href="https://tsch.js.org/4182/solutions" target="_blank"></a> <!--info-footer-end-->