yaworsw/euler-manager

View on GitHub
data/problems/394.yml

Summary

Maintainability
Test Coverage
---
:id: 394
:name: Eating pie
:url: https://projecteuler.net/problem=394
:content: "Jeff eats a pie in an unusual way.  \nThe pie is circular. He starts with
  slicing an initial cut in the pie along a radius.  \nWhile there is at least a given
  fraction <var>F</var> of pie left, he performs the following procedure:  \n- He
  makes two slices from the pie centre to any point of what is remaining of the pie
  border, any point on the remaining pie border equally likely. This will divide the
  remaining pie into three pieces.  \n - Going counterclockwise from the initial cut,
  he takes the first two pie pieces and eats them.  \nWhen less than a fraction <var>F</var>
  of pie remains, he does not repeat this procedure. Instead, he eats all of the remaining
  pie.\n\n![p394_eatpie.gif]({{ images_dir }}/p394_eatpie.gif)\n\nFor <var>x</var>
  ≥ 1, let E(<var>x</var>) be the expected number of times Jeff repeats the procedure
  above with <var>F</var> = <sup>1</sup>/<sub><var>x</var></sub>.  \nIt can be verified
  that E(1) = 1, E(2) ≈ 1.2676536759, and E(7.5) ≈ 2.1215732071.\n\nFind E(40) rounded
  to 10 decimal places behind the decimal point.\n\n"