Няма описание
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Michael Mächtel 8ed7ea6a09 INIT: task2 преди 8 години
..
src INIT: task2 преди 8 години
tests INIT: task2 преди 8 години
README.md INIT: task2 преди 8 години

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.