Advertisement
zarkoto223

aboveMainDiagAlphaPrep

Dec 24th, 2023
763
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let rows = parseInt(gets());
  2.  
  3. let matrix = [];
  4.  
  5. for (let i = 0; i < rows; i++) {
  6.     let row = [];
  7.     for (let j = 0; j < rows; j++) {
  8.         if (j === 0) {
  9.             row.push(2 ** i);
  10.         } else {
  11.             row.push(row[j - 1] * 2);
  12.         }
  13.     }
  14.     matrix.push(row);
  15. }
  16.  
  17. let sumAboveDiagonal = BigInt(0);
  18.  
  19. for (let i = 0; i < rows; i++) {
  20.     for (let j = i + 1; j < rows; j++) {
  21.         let currentNumber = BigInt(matrix[i][j]);
  22.         sumAboveDiagonal += currentNumber;
  23.     }
  24. }
  25.  
  26. console.log(sumAboveDiagonal.toString());
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement