Explore BrainMass

Visual C++

Write a C++ value returning function that implements the recursive formula
F(n) = F(n-1) + F(n+2) with base cases F(0)=1 and F(1) =1

Solution Preview

#include <iostream>
using namespace std;
long fib_num(long);

int main(){

long num = 0;
long sequence = 0;

cout << "Please enter a natural number : ";

Solution Summary

Visual C++ is modeled.