Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Calculate Grains on a given square on a chessboard js

//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}`);
 
PREVIOUS NEXT
Tagged: #Calculate #Grains #square #chessboard #js
ADD COMMENT
Topic
Name
3+9 =