// Programación en C++ para Ingenieros, Ed. Thomson Paraninfo, 2006
// Capítulo 4: Esquemas Algorítmicos Básicos

// Programa que calcula el natural n>0 menor tal que n^3 + n^2 + n - 1876119 > 0.

#include <iostream>

using namespace std;

// Definición de constantes
const int a = 1876119;

// Programa principal
int main()
{
  // Declaración de variables
  int f, x = 1, y = 1, z = 1, k = 1;

  f = x + y + z;

  // Propiedad del último elemento
  while ( f <= a )
  {
    x = x + 3 * y + 3 * z + 1;
    y = y + 2 * z + 1;
    z = z + 1;
    f = x + y + z;
    k = k + 1;
  }

  cout << "El menor natural n>0 tal que n^3+n^2+n-1876119>0 es " << k << endl;

  return 0;
}