From cddebd50070ee7390f315b405804a48f728c8d8b Mon Sep 17 00:00:00 2001 From: Theerthababu <44488377+Theerthababu@users.noreply.github.com> Date: Tue, 30 Oct 2018 21:24:31 +0530 Subject: [PATCH] Add files via upload --- gosefile.cpp | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 gosefile.cpp diff --git a/gosefile.cpp b/gosefile.cpp new file mode 100644 index 0000000..a6d2b3d --- /dev/null +++ b/gosefile.cpp @@ -0,0 +1,71 @@ +#include + +int fibo(int); + + + +int main() + +{ + + int num; + + int result; + + + + printf("Enter the nth number in fibonacci series: "); + + scanf("%d", &num); + + if (num < 0) + + { + + printf("Fibonacci of negative number is not possible.\n"); + + } + + else + + { + + result = fibo(num); + + printf("The %d number in fibonacci series is %d\n", num, result); + + } + + return 0; + +} + +int fibo(int num) + +{ + + if (num == 0) + + { + + return 0; + + } + + else if (num == 1) + + { + + return 1; + + } + + else + + { + + return(fibo(num - 1) + fibo(num - 2)); + + } + +}