Grains on a Chessboard
JavaScript
10 pts
Grains on a Chessboard
An old story: a king puts 1 grain of rice on the first square of a chessboard, 2 on the second, 4 on the third, doubling every time. On all 64 squares there are 264 − 1 grains.
- Create
totalas a BigInt:2n ** 64n - 1n. Print it. - Print the same calculation with normal numbers:
2 ** 64 - 1(see how it loses the last digits). - Print the type of
total.
Expected output:
18446744073709551615n 18446744073709552000 bigint
Checklist
- Create
totalas a BigInt calculation. - Print the normal-number version too.
- The three lines match.
🔑 Solution
If you view the solution before passing, you earn half points for this exercise. You still need to type it and press Check to finish.
How it works, step by step
Point at a step to highlight its lines. Type the solution yourself and press Check answer to finish.
