#include #include #include #include #include "number.h" Number fib(int n) { Number a = 0; // F0 Number b = 1; // F1 for (int i = 1; i <=n; ++i) { if (i % 2) { a += b; } else { b += a; } } if (n % 2) { return b; } return a; } Number factorial(int n) { Number result{1}; for (int i = 2; i < n + 1; ++i) { result = Number(i) * result; } return result; } void grad(Number n) { std::cout << "n = " << n; Number max = n; unsigned long long int steps = 0; while (n != Number(1)) { if (n > max) { #ifdef _DEBUG_COMP std::cout << n << " is greater than " << max << std::endl; #endif max = n; } if (n.isEven()) { n.div2(); } else { n = Number(3) * n + Number(1); } #ifdef _DEBUG_GRAD if(steps > 100) { std::cout << "break" << std::endl; break; } #endif ++steps; } std::cout << " steps = " << steps << " max = " << max << std::endl; } int main() { std::cout << fib(1000) << std::endl; //x = x * Number(24)*Number{25}; //y = factorial(5); //std::cout << x << " " << x.capacity << " " << x.size << std::endl; //std::cout << y << " "<< y.capacity << " " << y.size << std::endl; //std::cout << "===" << std::endl << Number(2) * Number(3) << " "<< Number(3) * Number(2) << std::endl; //std::cout << "5! = " << Number(2) * Number(3) * Number(4) * Number(5) << std::endl; //std::cout << factorial(1000) << std::endl; //std::cout << Number("620448401733239439360000") * Number(25) << std::endl; //std::cout << (y < x) << std::endl; //grad(Number("4761963248413673697")); //grad(Number("256")); //std::cout << Number(128) * Number(3) + Number(1) + Number(2) + Number(3) + Number(4) << std::endl; }