Skip to content

Constexpr Fibonachi

This is fun implementation of the Fibonachi function:

template<int N>
constexpr int fibo() {
    if constexpr (N >= 2) {
        return fibo<N - 1>() + fibo<N - 2>();
    } else {
        return N;
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *