Nenhuma descrição
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
Michael Mächtel 8ed7ea6a09 INIT: task2 8 anos atrás
..
src INIT: task2 8 anos atrás
tests INIT: task2 8 anos atrás
README.md INIT: task2 8 anos atrás

README.md

Homework hw1 task 2

prepare your task

Run cargo init in your task2/ directory.

task

Calculate the number of grains of wheat on a chessboard given that the number on each square doubles.

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 chess board. Two grains on the next. Four on the third, and so on.

There are 64 squares on a chessboard.

Write code that shows:

  • how many grains were on each square (fn square(n: u32) -> u64), and
  • the total number of grains (fn total() -> u64)

Use the given file lib.rs for your solution.