The lightness of led changes from dark to bright and from bright to dark

I bought a reference book to learn Arduino, it told me to edit this code to the function (The lightness of led changes from dark to bright and from bright to dark automatically.)

I have thought for a long time, but still can’t figure out how to do it.

Please help me with it, in the simplest way.

Thanks a lot.

const int led=10;
int brightness=0;
int lighten=5;
void setup()
{ 

}

void loop() 
{
analogWrite(led,brightness);
if(brightness<=250)
   brightness=brightness+lighten;
else
   brightness=0;
delay(50);
}

Try this variation

const int led = 10;
int brightness = 0;
int delta = 1;

void setup()
{ 

}

void loop() 
{
  analogWrite(led, brightness);

  // reverse direction needed?
  if (brightness >= 255 - delta) delta = -delta;  
  if (brightness <= 0 + delta) delta = -delta;

  brightness=brightness + delta;

  delay(50);
}