#include <iostream>
#include <math.h>
 
using namespace std;
 
float FuncFloat(float n);
double FuncDouble(double n);
 
int main(){
 
/*Testing Binet's Function for F(n)=result. 
We are going to set N to 10 for these examples. 
The 1st is sending and returning a float = 7 digits*
The 2nd one is supposed to return a double = 15 digits*/
 
	cout<<"Online Fibonacci Calculators say = F(10) = 55 (2 digits)"<<endl<<endl;
 
	float test1 = 10;
	cout<<"Using FLOAT - F(10) = "<<FuncFloat(test1);
 
	cout<<endl<<endl;
 
	double test2=10;
	cout<<"Using DOUBLE - F(10) = "<<FuncDouble(test2);
 
//----------------------------------------------------------------------------------------------
 
	cout<<endl<<endl;
 
/*Testing Binet's Function for F(n)=result. 
We are going to set N to 30 for these examples. 
The 1st is sending and returning a float = 7 digits*
The 2nd one is supposed to return a double = 15 digits*/
	cout.precision(15);
	cout<<"Online Fibonacci Calculators say = F(30) = 832040  (6 digits)"<<endl<<endl;
 
	test1 = 30;
	cout<<"Using FLOAT - F(30) = "<<FuncFloat(test1);
 
	cout<<endl<<endl;
 
	test2=30;
	cout<<"Using DOUBLE - F(30) = "<<FuncDouble(test2);
 
//----------------------------------------------------------------------------------------------
 
	cout<<endl<<endl;
 
/*Testing Binet's Function for F(n)=result. 
We are going to set N to 31 for these examples. 
The 1st is sending and returning a float = 7 digits*
The 2nd one is supposed to return a double = 15 digits*/
 
	cout<<"Online Fibonacci Calculators say = F(31) = 1346269   (7 digits)"<<endl<<endl;
 
	test1 = 31;
	cout<<"Using FLOAT - F(31) = "<<FuncFloat(test1);
 
	cout<<endl<<endl;
 
	test2=31;
	cout<<"Using DOUBLE - F(31) = "<<FuncDouble(test2);
 
 
//WHY dose the double sill error.. it is meant to be 15 digits, there should be plenty of room for this F(30) number?
 
 
 
	cout<<endl<<endl<<endl<<"Please Close Console Window"<<endl;
	cin.ignore('\n', 1024);
	return(0);
}
 
 
float FuncFloat(float n){
	float result;
	result = (pow(1 + sqrt(5.0f), n) - pow( 1 - sqrt(5.0f),n )) / (pow(2,n) * sqrt(5.0f));
	return(result);
}
 
 
 
double FuncDouble(double n){
	double result;
	result = (pow(1 + sqrt(5.0), n) - pow( 1 - sqrt(5.0),n )) / (pow(2,n) * sqrt(5.0));
	return(result);
}