fibonacci number Algorithm

Fibonacci numbers are strongly related to the golden ratio: Binet's formula expresses the nth Fibonacci number in terms of N and the golden ratio, and imply that the ratio of two consecutive Fibonacci numbers tends to the golden ratio as n increases. In his 1202 book Liber Abaci, Fibonacci introduced the sequence to Western European mathematics, although the sequence had been described earlier in Indian mathematics, as early as 200 BC in work by Pingala on enumerating possible shapes of Sanskrit poetry formed from syllables of two lengths. At the end of the nth month, the number of pairs of rabbits is equal to the number of mature pairs (that is, the number of pairs in month N – 2) plus the number of pairs alive last month (month N – 1). At the end of the fourth month, the original pair has produced yet another new pair, and the pair birth two months ago also produces their first pair, make 5 pairs. Fibonacci considers the increase of an idealized (biologically unrealistic) rabbit population, assume that: a newly birth breeding pair of rabbits are put in a field; each breeding pair mates at the age of one month, and at the end of their second month they always produce another pair of rabbits; and rabbits never die, but continue breeding forever.
#include <iostream>
int fibonacci_fast(int n) {
    // write your code here
    int fin[n];
    fin[0]=0;
    fin[1]=1;
    for (int i=2;i<=n;i++)
    	fin[i]=fin[i-1]+fin[i-2];

    return fin[n];
}
int main() {
    int n = 0;
    std::cin >> n;

    std::cout << fibonacci_fast(n) << '\n';
    return 0;
}

LANGUAGE:

DARK MODE: