Hello.I have some problem. I musc count fibonacci's 150 member. As i know borders of int isn't enought so here we need BigInt.I have ready project of counting but i need to include bigint here and here i need help.
#include <iostream>
usingnamespace std;
class Fibonacci{
public:
int a, b, c;
void generate(int);
};
void Fibonacci::generate(int n){
a = 0; b = 1;
cout << a << " " <<b;
for(int i=1; i<= n-2; i++){
c = a + b;
cout << " " << c <<endl;;
a = b;
b = c;
}
}
int main()
{
cout << "Hello world! Fibonacci series" << endl;
cout << "Enter number of items you need in the series: ";
int n;
cin >> n;
Fibonacci fibonacci;
fibonacci.generate(n);
system("pause");
return 0;
}
also i have working class of BigInt and want to include here.
#include <iostream>
#include <boost/multiprecision/cpp_int.hpp> // include the header
// link with the library if it is not a header-only libray
namespace Fibonacci {
using big_int = boost::multiprecision::cpp_int ;
void generate( unsignedint n ) {
big_int a = 0 ;
big_int b = 1 ;
std::cout << "\n1. " << a << "\n2. " << b << '\n' ;
for( unsignedint i = 2 ; i < n ; ++i ) {
const big_int c = a+b ;
std::cout << i+1 << ". " << c << '\n' ;
a = b ;
b = c ;
}
}
};
int main()
{
std::cout << "Hello world! Fibonacci series\n""Enter number of items you need in the series: ";
unsignedint n;
std::cin >> n;
Fibonacci::generate(n);
}