How to use binary to digitalwrite

I'm having little trouble with using binary and bitwise operator to make led work. I"m using inputs 2,3,4,5 and trying to turn it on by following mechanism.
2(on)
2,3(on)
2,3,4(on)
2,3,4,5(on)
2,3,4(on)
2,3 (on)
2 (on)

Below is the general skeleton code I've created using bitwise operator. But how do I apply this to digitalWrite??? I need help.

int pattern=1, shift;
if (index<4) shift = index;
else shift = 6-index;

for (int i=0; i<shift; i++)
pattern = (pattern << 1) | 0x01;

It's all here:- Arduino Reference - Arduino Reference

One possibility:

Iterate through pattern using the value of the iterator to do a bit.read on each bit in turn. If the bit is on/off set/reset the corresponding digital output. If the digital outputs aren't contiguous you can set up an array which holds the output pin numbers and retrieve them with the iterator as an index.

I don't really get why you think you need bitwise operations or direct port manipulation at all...

First part is as simple as (just as an example with bad delay()'s and blocking loops etc)

const byte LedPins[] = {2, 3, 4, 5};
const byte NrLeds = sizeof(LedPins);

void setup(){
  for(byte i = 0; i < NrLeds; i++){
    pinMode(LedPins[i], OUTPUT);
  }
}

void loop(){
  //patern loop
  for(byte i = 1; i <= NrLeds; i++){
    
    //loop all to set them in the correct state
    for(byte j = 0; j < NrLeds; j++){
      digitalWrite(LedPins[j], j < i);
    }
    
    delay(1000);
  }