Loop to add previous three numbers for each number starting from 3 and then assign first , second , third to second , third , and curr to third respectively
for ( int i = 3 ; i < n ; i ++ ) { int curr = first + second + third ; first = second ; second = third ; third = curr ; cout << curr << " ▁ " ; } }