Ad
  • Custom User Avatar

    I've had a think and, having thunk, I've removed the closed form, but also amended the description to make it clear that such a thing exists.

    Appreciate the feedback!

  • Custom User Avatar

    It's a very valid question and represents that I'm in two minds over this. In line with exactly your point, the original description didn't include a closed form. However, the initial comments when I put this up as a potential Kata suggested that just having the recursive definition looked confusing, so I subsequently altered it to include one of the direct methods of computation knowing that it took away from the original spirit.

    I guess I just need to decide whether to revert to my original proposal, but, as this is my first attempt at a Kata, I'm more than happy to hear both what people think...

  • Default User Avatar

    ain't no way bro said ** nods head **

  • Custom User Avatar

    ** nods head ** I know, and I completely understand. I tried both styles side by side and I genuinely prefer that L/KaTeX style for mathematical expressions...

  • Custom User Avatar

    I don;t mean to enforce any specific form of the formula, I only wanted to point out the possibility of a nice formating of exponents and subscripts.

  • Custom User Avatar

    Very much obliged on the suggestion of KaTeX: I did wonder if methematical notation was possible, but don't know LaTeX. I've updated the look and feel of the formulae side of things to use KaTeX and also included a non-recursive definition of the swinging factorial function which looks a bit less ... technical ...

  • Custom User Avatar

    That's the algorithmic form of the equation; it makes no sense to directly translate it for a math representation.

    For a math representation it should be replaced with the usual

    f(n) = x    if n is even
    f(n) = y    otherwise
    
  • Custom User Avatar
    ```math
    \begin{cases}
       a_0 = 1 \\
       a_n = n^{n \text{ mod } 2} * (4/n)^{(n+1)\text{ mod } 2} * a_{n-1} &\text{for } n \geqslant 1
    \end{cases}
    ```
    
    \begin{cases}
       a_0 = 1 \\
       a_n = n^{n \text{ mod } 2} * (4/n)^{(n+1)\text{ mod } 2} * a_{n-1} &\text{for } n \geqslant 1
    \end{cases}
    

    You could make it simpler by replacing \text{ mod } with an operator like %.

  • Custom User Avatar

    Consider KaTeX for the formula part https://katex.org/docs/supported .

    I will try to prepare an example.

  • Custom User Avatar

    I've added a small note to the description to try and clarify this...

  • Custom User Avatar

    There are no floats involved in the calculation, only the formula representation make it seem like so; if you're worried you can always use fractions instead, though all terms will end up integral (as it should be).

  • Custom User Avatar

    It's more the precision I was worried about. There are floating point divisions in there.

  • Custom User Avatar

    The tests aren't really performance heavy, so going by the definition or the explicit formula will both work.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Fair question; part of the Kata was to look up a straightforward method to calculate the values (hence the references in the hints). Perhaps I should make this a bit more explicit in the description..?

  • Loading more items...