5 kyu

Getting along with Bernoulli's numbers

4 of 204g964
Description
Loading description...
Fundamentals
Mathematics
  • Please sign in or sign up to leave a comment.
  • ahmet_popaj Avatar

    A mathy kata, congratulations.

  • saudiGuy Avatar
  • picadud Avatar

    the error grows larger with the test number since my solution always used the previous result(which is slight off) to calculate next one, is there a way to avoid this?(solved by using BigDecimal type in scala)

  • B1ts Avatar

    Perl has some issues with random tests:

    No tests run! Can't locate object method "new" via package "Math::BigRat"

  • SeveralPeople-a Avatar

    Please mark case 2 more clearly. It is ambiguous whether or not the |B_{k}| term is inside the denominator or just multiplied by (\frac{1}{2}).
    Problem code:

    • \bg_green f(k) = 1/2 |B_k| (2\pi)^{k} / k!

    Proposed solutions:

    • \bg_green f(k) = (1/2) |B_k| (2\pi)^{k} / k!
    • \bg_green f(k) = \frac{1}{2} |B_k| (2\pi)^{k} / k!
  • victorvishnyakov Avatar

    I am trying to solve this task in c++. It turns out that the time is running out, but if I specify some values of the Bernoulli numbers, say if (N==26) { return (double) 8553103/6; } then the program works if you specify several such values ( I calculate the Bernoulli numbers recursively). But this decision is not entirely fair, right? That's why I'm trying to find ways to reduce the work of the program.

  • Abirino Avatar

    A bit confused with the second formula. I passed the tests but in the attempt failed for 14 and 18. Are there any parenthesis in the formula?

    1/2|Bk|2PI^k/k!

    Is it (1/2)* |Bk|* (2PI^k/k!) or?

  • JohanWiltink Avatar
  • JohanWiltink Avatar

    I was hoping f (1) would have an O(1) solution. I did find the name "p-series" for the infinite series, and a sum formula for the whole infinite series ( hello Riemann zeta-function! Now we know where f (2) comes from .. ), but not for finite prefixes of it.

    Is there really nothing better than summing 100 000 values?

  • JohanWiltink Avatar

    ( JS, possibly others )

    Reference f -27 and f -29 are incorrect before the 6th decimal.

    f -27 = b 28 / -28 = -23749461029 / 870 / -28 = 3392780147 / 3480 = 974936.8238505747 /= 974936.8238560227

    f -29 = b 30 / -30 = 8615841276005 / 14322 / -30 = -1723168255201 / 85932 = -20052695.79668808 /= -20052695.797136296

    Bernoulli numbers are rational numbers and can be calculated exactly. The reference solution, however, approximates them as floating point numbers, and accumulates errors when calculating them.

  • JohanWiltink Avatar

    It's approvable, but most languages have no solutions yet.

    Maybe wait a little.

    Author, whenever you feel it's really ready, please resolve this issue.

  • Blind4Basics Avatar

    the second formula has an extra closing parenthese

  • ZED.CWT Avatar

    Python Translation Please review carefully

  • ZED.CWT Avatar

    JavaScript Translation Please review carefully

  • Voile Avatar

    I assume you're aware of this kata's presence, right? ;-)