Fibonacci

Download Category:

Fibonacci.zip - (354.92 KB)
[
Fibonacci/Debug/
Fibonacci/Debug/cl.command.1.tlog
Fibonacci/Debug/CL.read.1.tlog
Fibonacci/Debug/CL.write.1.tlog
Fibonacci/Debug/Fibonacci.exe
Fibonacci/Debug/Fibonacci.exe.embed.manifest
Fibonacci/Debug/Fibonacci.exe.embed.manifest.res
Fibonacci/Debug/Fibonacci.exe.intermediate.manifest
Fibonacci/Debug/Fibonacci.ilk
Fibonacci/Debug/Fibonacci.lastbuildstate
Fibonacci/Debug/Fibonacci.log
Fibonacci/Debug/Fibonacci.obj
Fibonacci/Debug/Fibonacci.pdb
Fibonacci/Debug/Fibonacci.vcxprojResolveAssemblyReference.cache
Fibonacci/Debug/Fibonacci.write.1.tlog
Fibonacci/Debug/Fibonacci_manifest.rc
Fibonacci/Debug/link.2140.read.1.tlog
Fibonacci/Debug/link.2140.write.1.tlog
Fibonacci/Debug/link.2140-cvtres.read.1.tlog
Fibonacci/Debug/link.2140-cvtres.write.1.tlog
Fibonacci/Debug/link.command.1.tlog
Fibonacci/Debug/link.read.1.tlog
Fibonacci/Debug/link.write.1.tlog
Fibonacci/Debug/link-cvtres.read.1.tlog
Fibonacci/Debug/link-cvtres.write.1.tlog
Fibonacci/Debug/mt.command.1.tlog
Fibonacci/Debug/mt.read.1.tlog
Fibonacci/Debug/mt.write.1.tlog
Fibonacci/Debug/rc.command.1.tlog
Fibonacci/Debug/rc.read.1.tlog
Fibonacci/Debug/rc.write.1.tlog
Fibonacci/Debug/vc100.idb
Fibonacci/Debug/vc100.pdb
Fibonacci/Fibonacci.cpp
Fibonacci/Fibonacci.sln
Fibonacci/Fibonacci.suo
Fibonacci/Fibonacci.vcxproj
Fibonacci/Fibonacci.vcxproj.filters
Fibonacci/Fibonacci.vcxproj.user
Fibonacci/Question.txt
Fibonacci/Screenshot_2.png
]

The Fibonacci sequence is defined as follows. If Fib(k) denotes the kth number in the Fibonacci sequence, then, for non-negative positions in the sequence,

Fib(1) = 1

Fib(2) = 1

Fib(n) = Fib(n-1) + Fib(n-2)

In English, we may say that a Fibonacci number is ***** sum of its two immediate predecessors, except for the first two Fibonacci numbers, which are both 1.

Implement a class called Fibonacci. This class should provide a single class method (static) with the following signature:

double Fibonacci::getNthFibonacciRecursively(int n)

which should do exactly that. It calculates and returns the nth Fibonacci number and does so recursively, by invoking itself for certain input values of n. Note that its parameter n is an integer, but its return value is a double. Why? Answer this question in a single short sentence within the header comment of this method.

From your main(), issue calls to Fibonacci for various values of n in the range 1 to 10 and make sure that the output concurs with your paper-and-pencil calculation. Handle the case for n <= 0 by returning an invalid value and note it in the documentation of the function (within comments). For example you’d say that the function will return -1 for n <= 0. That’s perfectly acceptable.

Write a Review

Get a fresh solution of this question. Ask it now to our experts.
doubt

Ask Your Question

We have verified professionals who are ready to answer your question.

time

Save Time and Money

We choose experts who can quickly answer your question and that suit your budget.

download

Get Your Answer

Your satisfaction is 100% guaranteed. You can keep on asking questions until you get the answer you need.