#include using namespace std; bool Fibon_Elem(int pos, int& elem) { bool ret = false; elem = 1; int first = 1, second = 1; if (pos <= 0) { return ret; } 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; } }