How do I do this program?

So the goal changes: upon a button press, you want to display the first 5 powers of 2, form 0 to 4 included.

Write a function such as this one:

void display_powers_of_2 (void)
{
    const unsigned int MAX_EXP = 4; 
    unsigned int result;
    
    for (unsigned int exp = 0; exp <= MAX_EXP; ++exp)
    {
        result = 1 << exp;

        Serial.print("2 to the power of ");
        Serial.print(exp);
        Serial.print(" is 0b");
        Serial.print(result, BIN);
        Serial.print(" in binary or ");
        Serial.print(result, DEC);
        Serial.print(" in decimal.\n");
    }
    return;
}

And invoke it when you detect a button press.