diff --git a/CPP/nth_fibonacci_number.cpp b/CPP/nth_fibonacci_number.cpp new file mode 100644 index 0000000..ffa428e --- /dev/null +++ b/CPP/nth_fibonacci_number.cpp @@ -0,0 +1,24 @@ +#include +using namespace std; +int fib(int n) +{ + int a = 0, b = 1, c, i; + if( n == 0) + return a; + for (i = 2; i <= n; i++) + { + c = a + b; + a = b; + b = c; + } + return b; +} + +int main () +{ + int n; + cout<<"Enter the term you want to get: "; + cin>>n; + cout<<"The fibonacci number is: "<