exercism/rust/grains
2025-12-10 18:04:56 +03:00
..
.exercism grains is easy 2025-12-10 18:04:56 +03:00
src grains is easy 2025-12-10 18:04:56 +03:00
tests grains is easy 2025-12-10 18:04:56 +03:00
.gitignore grains is easy 2025-12-10 18:04:56 +03:00
Cargo.toml grains is easy 2025-12-10 18:04:56 +03:00
HELP.md grains is easy 2025-12-10 18:04:56 +03:00
README.md grains is easy 2025-12-10 18:04:56 +03:00

Grains

Welcome to Grains on Exercism's Rust Track. If you need help running the tests or submitting your code, check out HELP.md.

Introduction

There once was a wise servant who saved the life of a prince. The king promised to pay whatever the servant could dream up. Knowing that the king loved chess, the servant told the king he would like to have grains of wheat. One grain on the first square of a chessboard, with the number of grains doubling on each successive square.

Instructions

Calculate the number of grains of wheat on a chessboard.

A chessboard has 64 squares. Square 1 has one grain, square 2 has two grains, square 3 has four grains, and so on, doubling each time.

Write code that calculates:

  • the number of grains on a given square
  • the total number of grains on the chessboard

Source

Created by

  • @IanWhitney

Contributed to by

  • @ClashTheBunny
  • @coriolinus
  • @cwhakes
  • @efx
  • @ErikSchierboom
  • @krodyrobi
  • @lutostag
  • @navossoc
  • @nfiles
  • @petertseng
  • @rofrol
  • @stringparser
  • @TheDarkula
  • @xakon
  • @ZapAnton

Based on

The CodeRanch Cattle Drive, Assignment 6 - https://web.archive.org/web/20240908084142/https://coderanch.com/wiki/718824/Grains