yaworsw/euler-manager

View on GitHub
data/problems/335.yml

Summary

Maintainability
Test Coverage
---
:id: 335
:name: Gathering the beans
:url: https://projecteuler.net/problem=335
:content: |+
  Whenever Peter feels bored, he places some bowls, containing one bean each, in a circle. After this, he takes all the beans out of a certain bowl and drops them one by one in the bowls going clockwise. He repeats this, starting from the bowl he dropped the last bean in, until the initial situation appears again. For example with 5 bowls he acts as follows:

   ![p335_mancala.gif]({{ images_dir }}/p335_mancala.gif)

  So with 5 bowls it takes Peter 15 moves to return to the initial situation.

  Let <var>M</var>(<var>x</var>) represent the number of moves required to return to the initial situation, starting with <var>x</var> bowls. Thus, <var>M</var>(5) = 15. It can also be verified that <var>M</var>(100) = 10920.

  Find ![p335_sum.gif]({{ images_dir }}/p335_sum.gif)<var>M</var>(2<sup><var>k</var></sup>+1). Give your answer modulo 7<sup>9</sup>.