yaworsw/euler-manager

View on GitHub
data/problems/285.yml

Summary

Maintainability
Test Coverage
---
:id: 285
:name: Pythagorean odds
:url: https://projecteuler.net/problem=285
:content: "Albert chooses a positive integer <var>k</var>, then two real numbers <var>a</var>,
  <var>b</var> are randomly chosen in the interval [0,1] with uniform distribution.
  \ \nThe square root of the sum (<var>k</var>·<var>a</var>+1)<sup>2</sup> + (<var>k</var>·<var>b</var>+1)<sup>2</sup>
  is then computed and rounded to the nearest integer. If the result is equal to <var>k</var>,
  he scores <var>k</var> points; otherwise he scores nothing.\n\nFor example, if <var>k</var> = 6,
  <var>a</var> = 0.2 and <var>b</var> = 0.85, then (<var>k</var>·<var>a</var>+1)<sup>2</sup> + (<var>k</var>·<var>b</var>+1)<sup>2</sup> = 42.05.
  \ \nThe square root of 42.05 is 6.484... and when rounded to the nearest integer,
  it becomes 6.  \nThis is equal to <var>k</var>, so he scores 6 points.\n\nIt can
  be shown that if he plays 10 turns with <var>k</var> = 1, <var>k</var> = 2, ...,
  <var>k</var> = 10, the expected value of his total score, rounded to five decimal
  places, is 10.20914.\n\nIf he plays 10<sup>5</sup> turns with <var>k</var> = 1,
  <var>k</var> = 2, <var>k</var> = 3, ..., <var>k</var> = 10<sup>5</sup>, what is
  the expected value of his total score, rounded to five decimal places?\n\n"