123456789101112131415161718192021222324252627282930313233343536373839404142 |
- #include "utils.h"
- #include <limits>
- vector<u32>* fibon_seq(int size) {
- static vector<u32> elems;
- if (size <= 0 || size > 1024) {
- cout << "size is invalid!" << endl;
- return 0;
- }
-
- int current_size = elems.size();
- if (size > current_size) {
- for (int ix = current_size; ix < size; ++ix) {
- if (ix < 2) {
- elems.push_back(1);
- }
- else {
- int value_ix = elems[ix - 1] + elems[ix - 2];
- elems.push_back(value_ix);
- }
-
- }
- }
- return &elems;
- }
- int main() {
- vector<u32>* v = fibon_seq(100);
- if (v) {
- display(*v);
- }
-
- int max_int = numeric_limits<long>::max();
- cout << max_int << endl;
- return 0;
- }
|