5 kyu
Getting along with Bernoulli's numbers
4 of 204g964
Loading description...
Fundamentals
Mathematics
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
A mathy kata, congratulations.
python new test framework
Already approved by someone
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)
Perl has some issues with random tests:
I tried the existing solutions and had no problem (yours among them,; it passed!)... See: "https://metacpan.org/pod/Math::BigRat".
Yes they pass, but random tests aren't even run! (at least nothing was logged to console after sample ones)
Here's what I see in output window:
It looks like it runs only the first or first 2 tests, then crashes.
Ah, here's the line:
That's in your ref solution I believe, but BigRat isn't imported anywhere.
Yes, I used BigRat without importing it. I just added it in the Tests Cases. Can you try again?
Note: I don't understand why it worked for others' solutions without that import unless I have not seen all the ouput.
Looks good now. Perl is mysterious ;-)
Thanks!
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:
Proposed solutions:
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.
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?
0.5 * abs(B(k)) * (pow(2 * pi, k) / factorial(k)
Thanks I think it is probkem with the type I am using have to use Big Integers. Fun kata btw!
Haskell translation
Approved!
I was hoping
f
(1) would have anO(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 wheref
(2) comes from .. ), but not for finite prefixes of it.Is there really nothing better than summing
100 000
values?( JS, possibly others )
Reference
f -27
andf -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.
This comment has been hidden.
Ah, yes, that'll work as well.
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.
I will wait; Java, C#, C++, Scala are from today... Thanks!
Thanks for your understanding!
6 months. Maybe I have waited enough...
the second formula has an extra closing parenthese
I think it is fixed. Good eye! Thanks!
yep
Python Translation Please review carefully
Approved, I trust you!-)
But.. i dont trust myself. O_o // So you are reviewing the JS one ?
JS approved. I didn't see any problem in JS and Python translations but is it a proof?-)
It is a proof depends on whether i trust you. Apparently, yes. o_O
JavaScript Translation Please review carefully
Reference
f -27
andf -29
are incorrect before the 6th decimal. ( See issue above. )Maybe use precalculated Bernoulli numbers?
I assume you're aware of this kata's presence, right? ;-)
Yes since I mention it in the description, didn't you see that mention? I don't think it is a duplicate, I use Bernoulli numbers but it is not the aim of the kata. Do you think I must change the title?
Oh, I didn't notice the link in the descriptions (there are too much other stuff ;-)).
Well, I'm not trying to say or imply this kata's a duplicate, just pointing out there is such a kata ;-)
Maybe you could translate it or them. I will - if I have time - try to translate the @justyFY's one to Ruby.