From d70173bba97e8f11c9df513b49ae00674dbb5d76 Mon Sep 17 00:00:00 2001 From: PRIYANSHU TRIVEDI <33357862+PRIYANSHU-AMBITION@users.noreply.github.com> Date: Tue, 1 Oct 2019 21:04:45 +0530 Subject: [PATCH] create dynamic_fibonacci_series.cpp This gives the complete fibonacci series upto the desired term, not just the fibonacci no. of the the term entered. For example: if someone enters 5, it will give the output in terms of series of fibonacci no. upto first 5 numbers. ex.: input- 5, output- 0 1 1 2 3 --- Fibonacci/dynamic_fibonacci_series.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Fibonacci/dynamic_fibonacci_series.cpp diff --git a/Fibonacci/dynamic_fibonacci_series.cpp b/Fibonacci/dynamic_fibonacci_series.cpp new file mode 100644 index 0000000..3c9f9bb --- /dev/null +++ b/Fibonacci/dynamic_fibonacci_series.cpp @@ -0,0 +1,25 @@ +#include +using namespace std; +int fibonacci(int n) +{ + if ((n==1)||(n==0)) + { + return n; + } + else + { + return (fibonacci(n-1)+fibonacci(n-2)); + } +} +int main() +{ + int n,i=0; + cout<<"\n input the no. of terms for fibonacci series"; + cin>>n; + while(i