#include using namespace std; bool Fibon_Elem(int pos, int& elem) { if (pos >= 1024 || pos <= 0) { elem = 0; return false; } elem = 1; int first = 1, second = 1; for (int ix = 3; ix <= pos; ++ix) { elem = first + second; first = second; second = elem; } return true; } int main() { int elem = 0; bool ret = false; for (int i = 0; i < 10; ++i) { ret = Fibon_Elem(i, elem); if (!ret) cout << "Position " << i <<" is invalid!" << endl; else cout << "ret=" << ret << " " << elem << endl; } }