📜  计算棋盘js上给定方块上的谷物 - Javascript代码示例

📅  最后修改于: 2022-03-11 15:04:30.511000             🧑  作者: Mango

代码示例1
//Calculate Grains on a given square on a chessboard
const totalGrains = 2 ** 64 - 1;

const grainsOn = (input) => {
  const grainCount = 2 ** (input - 1);
  return grainCount;
};
console.log(`Grains on 6th square: ${grainsOn(6)}`);
console.log(`Total grains on the Chess Board: ${totalGrains}`);