1, 2, 4, 8, 16, … 33?Beware of the matrix tornado!Golf a Custom Fibonacci SequenceLevenshtein distance & OEIS (Cops)The sequence of range-exponentiated integersCollection from a sequence that constitute a perfect squareThe first n numbers without consecutive equal binary digitsFind the $left(n^2right)^textth n$-gonal numberThe Highest DiceThe Nth Gryphon NumberReverse your code, reverse the OEIS

How many flight hours do the first retiring A380s have?

Pattern matching expressions that have been simplified

How much would we learn from observing an FTL starship fly by?

How does a human body spend energy on its organs?

Mindslavering a Mindslavered player?

Why are compartments in western European day trains falling out of fashion?

How do you help a new player evaluate complex multiclassing options without driving them and yourself crazy?

Did any significant programs or environments take advantage of the Rexx which came with PCDOS 7 (aka PCDOS 2000)?

What is the difference between normal mode and command line mode?

How did the USSR track Gagarin's Vostok-1 orbital flight? Was tracking capability an issue in the choice of orbit?

Conveying the idea of « go figure »

My passport's Machine Readable Zone is damaged. How do I deal with it?

Got $2 in the mail from the Pew Research Center, is this a scam?

80’s or earlier short fantasy about very “sweet” neighbours

Do I need to use capacitors when using an L7805CV voltage regulator?

Why is it recommended to combine WordPress and Godaddy for hosting?

What stops one country from issuing another country's passports?

“You are not paid to think, but to do X” is always wrong in the workplace?

Why give an android emotions?

Why is a living creature being frozen in carbonite in “The Mandalorian” so common when it seemed so risky in “The Empire Strikes Back?”

Why should interrupts be short in well configured system?

Sudo directive in /etc/sudoers.d doesn't work (but it's fine if it's in /etc/sudoers)

Why would anyone choose not use the lowlatency kernel?

Feeling burned-out in PhD. program and thinking about dropping out



1, 2, 4, 8, 16, … 33?


Beware of the matrix tornado!Golf a Custom Fibonacci SequenceLevenshtein distance & OEIS (Cops)The sequence of range-exponentiated integersCollection from a sequence that constitute a perfect squareThe first n numbers without consecutive equal binary digitsFind the $left(n^2right)^textth n$-gonal numberThe Highest DiceThe Nth Gryphon NumberReverse your code, reverse the OEIS






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;









24















$begingroup$


Challenge



Write a function/program that outputs either the n'th element, or the first n elements, in the well known number sequence:



 1, 2, 4, 8, 16 ...


Oh, wait... I forgot the first few numbers:



1, 1, 1, 1, 2, 4, 8, 16 ...


Heck, I'll add a few more for good measure:



1, 1, 1, 1, 2, 4, 8, 16, 33, 69, 146, 312, 673, 1463, 3202, 7050, 15605, 34705 ...



The numbers are Generalized Catalan numbers given by the (zero-indexed) formula:



$$a(n+1)= a(n) + sum_k=2^n-1 a(k)cdot a(n-1-k)$$



where



$$a(0)= a(1)= a(2)= a(3) = 1$$



This is OEIS A004149.



You may choose if you want to have the sequence zero- or one-indexed. The sequence must of course be the same, so you must rewrite the formula if you have it one-indexed.










share|improve this question











$endgroup$














  • $begingroup$
    Correct me if I'm wrong here, but the modification for a one-indexed formula is to change a(n-1-k) to a(n-k) , correct?
    $endgroup$
    – Sumner18
    Sep 19 at 14:08






  • 9




    $begingroup$
    This reminds me of The strong law of small numbers
    $endgroup$
    – Luis Mendo
    Sep 19 at 14:13

















24















$begingroup$


Challenge



Write a function/program that outputs either the n'th element, or the first n elements, in the well known number sequence:



 1, 2, 4, 8, 16 ...


Oh, wait... I forgot the first few numbers:



1, 1, 1, 1, 2, 4, 8, 16 ...


Heck, I'll add a few more for good measure:



1, 1, 1, 1, 2, 4, 8, 16, 33, 69, 146, 312, 673, 1463, 3202, 7050, 15605, 34705 ...



The numbers are Generalized Catalan numbers given by the (zero-indexed) formula:



$$a(n+1)= a(n) + sum_k=2^n-1 a(k)cdot a(n-1-k)$$



where



$$a(0)= a(1)= a(2)= a(3) = 1$$



This is OEIS A004149.



You may choose if you want to have the sequence zero- or one-indexed. The sequence must of course be the same, so you must rewrite the formula if you have it one-indexed.










share|improve this question











$endgroup$














  • $begingroup$
    Correct me if I'm wrong here, but the modification for a one-indexed formula is to change a(n-1-k) to a(n-k) , correct?
    $endgroup$
    – Sumner18
    Sep 19 at 14:08






  • 9




    $begingroup$
    This reminds me of The strong law of small numbers
    $endgroup$
    – Luis Mendo
    Sep 19 at 14:13













24













24









24


2



$begingroup$


Challenge



Write a function/program that outputs either the n'th element, or the first n elements, in the well known number sequence:



 1, 2, 4, 8, 16 ...


Oh, wait... I forgot the first few numbers:



1, 1, 1, 1, 2, 4, 8, 16 ...


Heck, I'll add a few more for good measure:



1, 1, 1, 1, 2, 4, 8, 16, 33, 69, 146, 312, 673, 1463, 3202, 7050, 15605, 34705 ...



The numbers are Generalized Catalan numbers given by the (zero-indexed) formula:



$$a(n+1)= a(n) + sum_k=2^n-1 a(k)cdot a(n-1-k)$$



where



$$a(0)= a(1)= a(2)= a(3) = 1$$



This is OEIS A004149.



You may choose if you want to have the sequence zero- or one-indexed. The sequence must of course be the same, so you must rewrite the formula if you have it one-indexed.










share|improve this question











$endgroup$




Challenge



Write a function/program that outputs either the n'th element, or the first n elements, in the well known number sequence:



 1, 2, 4, 8, 16 ...


Oh, wait... I forgot the first few numbers:



1, 1, 1, 1, 2, 4, 8, 16 ...


Heck, I'll add a few more for good measure:



1, 1, 1, 1, 2, 4, 8, 16, 33, 69, 146, 312, 673, 1463, 3202, 7050, 15605, 34705 ...



The numbers are Generalized Catalan numbers given by the (zero-indexed) formula:



$$a(n+1)= a(n) + sum_k=2^n-1 a(k)cdot a(n-1-k)$$



where



$$a(0)= a(1)= a(2)= a(3) = 1$$



This is OEIS A004149.



You may choose if you want to have the sequence zero- or one-indexed. The sequence must of course be the same, so you must rewrite the formula if you have it one-indexed.







code-golf number sequence recursion






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 19 at 14:19









Luis Mendo

85.3k8 gold badges100 silver badges308 bronze badges




85.3k8 gold badges100 silver badges308 bronze badges










asked Sep 19 at 12:10









Stewie GriffinStewie Griffin

43.2k11 gold badges113 silver badges278 bronze badges




43.2k11 gold badges113 silver badges278 bronze badges














  • $begingroup$
    Correct me if I'm wrong here, but the modification for a one-indexed formula is to change a(n-1-k) to a(n-k) , correct?
    $endgroup$
    – Sumner18
    Sep 19 at 14:08






  • 9




    $begingroup$
    This reminds me of The strong law of small numbers
    $endgroup$
    – Luis Mendo
    Sep 19 at 14:13
















  • $begingroup$
    Correct me if I'm wrong here, but the modification for a one-indexed formula is to change a(n-1-k) to a(n-k) , correct?
    $endgroup$
    – Sumner18
    Sep 19 at 14:08






  • 9




    $begingroup$
    This reminds me of The strong law of small numbers
    $endgroup$
    – Luis Mendo
    Sep 19 at 14:13















$begingroup$
Correct me if I'm wrong here, but the modification for a one-indexed formula is to change a(n-1-k) to a(n-k) , correct?
$endgroup$
– Sumner18
Sep 19 at 14:08




$begingroup$
Correct me if I'm wrong here, but the modification for a one-indexed formula is to change a(n-1-k) to a(n-k) , correct?
$endgroup$
– Sumner18
Sep 19 at 14:08




9




9




$begingroup$
This reminds me of The strong law of small numbers
$endgroup$
– Luis Mendo
Sep 19 at 14:13




$begingroup$
This reminds me of The strong law of small numbers
$endgroup$
– Luis Mendo
Sep 19 at 14:13










20 Answers
20






active

oldest

votes


















22

















$begingroup$


Python, 51 bytes





f=lambda n,k=2:n<3or k<n and f(k)*f(n-k-2)+f(n,k+1)


Try it online!



Simplifies the formula a bit:



$$a(n) = sum_k=2^n-1 a(k)cdot a(n-2-k)$$



$$ a(-1) = a(0)= a(1)= a(2) = 1$$






share|improve this answer












$endgroup$









  • 8




    $begingroup$
    Congrats on the 100k!!
    $endgroup$
    – Stewie Griffin
    Sep 19 at 17:39










  • $begingroup$
    Since I also arrived to this solution independently, I must say that the path towards it is a bit bumpy...
    $endgroup$
    – Erik the Outgolfer
    Sep 19 at 23:43


















10

















$begingroup$


Perl 6, 44 bytes





1,1,1,1,sum @_[2..*]Z*@_[@_-4...0,0]...*


Try it online!



Anonymous code block that returns a lazy infinite sequence of values. This pretty much implements the sequence as described, with the shortcut that it zip multiplies all the elements so far after the second element with the reverse of the list starting from the fourth element and adding an extra 1 at the end.



Explanation:



 # Anonymous code block
...* # Create an infinite sequence
1,1,1,1, # Starting with four 1s
# Where each new element is:
sum # The sum of
@_[2..*] # The second element onwards
Z* # Zip multiplied with
@_[@_-4...0 ] # The fourth last element backwards
,0 # And 1





share|improve this answer










$endgroup$





















    10

















    $begingroup$


    05AB1E, 14 13 11 bytes



    $ƒˆ¯Âø¨¨¨PO


    Try it online!



    Outputs the nth element, 0-indexed.



    $ # push 1 and the input
    ƒ # repeat (input+1) times
    ˆ # add the top of the stack (initially 1) to the global array
    ¯ # push the global array
    Â # and a reversed copy of it
    ø # zip the two together, giving a list of pairs
    ¨¨¨ # drop the last 3 pairs
    P # take the product of each pair (or 1 if the list is empty)
    O # take the sum of those products
    # after the last iteration, this is implicitly output;
    # otherwise, it's added to the global array by the next iteration





    share|improve this answer












    $endgroup$





















      7

















      $begingroup$

      JavaScript (ES6), 42 bytes



      A port of xnor's solution.



      0-indexed.





      f=(n,k=2)=>n<3||k<n&&f(k)*f(n+~++k)+f(n,k)


      Try it online!




      JavaScript (ES6),  83  75 bytes



      A faster, less recursive, but significantly longer solution.



      0-indexed.





      f=(n,i,a=[p=1])=>a[n]||f(n,-~i,[...a,p+=(h=k=>k<i&&a[k]*a[i-++k]+h(k))(2)])


      Try it online!






      share|improve this answer












      $endgroup$





















        7

















        $begingroup$

        Haskell, 49 43 39 bytes



        a n=max(sum[a k*a(n-2-k)|k<-[2..n-1]])1 


        Try it online!



        For n<3 the sum is 0, so max ... 1 raises it to 1.



        Edit: -6 bytes thanks to @Jo King.






        share|improve this answer












        $endgroup$





















          6

















          $begingroup$


          Wolfram Language (Mathematica), 36 bytes



          Sum[#0@i#0[#-i-1],i,3,#-1]/. 0->1&


          Try it online!



          1-indexed.



          The 2-indexed sequence is 4 bytes shorter: Sum[#0@i#0[#-i],i,#-4]/. 0->1&.
          Try it online!






          share|improve this answer










          $endgroup$









          • 2




            $begingroup$
            Impressive that this is shorter than the built in CatalanNumber !
            $endgroup$
            – erfink
            Sep 20 at 22:20


















          6

















          $begingroup$


          05AB1E, 17 13 bytes



          4Å1λ£₁λ¨Â¦¦s¦¦*O+


          Not shorter than the existing 05AB1E answer, but I wanted to try the recursive functionality of the new 05AB1E version as practice for myself. Could perhaps be golfed by a few bytes. EDIT: And it indeed can, see the recursive version of @Grimy's 05AB1E answer below, which is 13 bytes.



          Outputs the first $n$ items: Try it online.



          Could be changed to the 0-based $n$'th item when replacing £ with è: Try it online;

          or an infinite list by removing £: Try it online.



          Explanation:



          This implements the formula used in the challenge description like this:
          $a(n)= a(n-1) + sum_k=2^n-1(a(k)cdot a(n-1-k))$



          $a(0)=a(1)=a(2)=a(3)=1$





           λ # Create a recursive environment,
          £ # to output the first (implicit) input amount of results after we're done
          4Å1 # Start this recursive list with [1,1,1,1], thus a(0)=a(1)=a(2)=a(3)=1
          # Within the recursive environment, do the following:
          λ # Push the list of values in the range [a(0),a(n)]
          ¨ # Remove the last one to make the range [a(0),a(n-1)]
          Â # Bifurcate this list (short for Duplicate & Reverse copy)
          ¦¦ # Remove the first two items of the reversed list,
          # so we'll have a list with the values in the range [a(n-3),a(0)]
          s # Swap to get the [a(0),a(n-1)] list again
          ¦¦ # Remove the first two items of this list as well,
          # so we'll have a list with the values in the range [a(2),a(n-1)]
          * # Multiply the values at the same indices in both lists,
          # so we'll have a list with the values [a(n-3)*a(2),...,a(0)*a(n-1)]
          O # Take the sum of this list
          ₁ + # And add it to the a(n-1)'th value
          # (afterwards the resulting list is output implicitly)





          13 bytes version of @Grimy (make sure to upvote his answer if you haven't yet!):



          1λ£λ1šÂ¨¨¨øPO


          Outputs the first $n$ items: Try it online.



          Can again be changed to 0-based indexing or an infinite list instead:

          - (0-based) indexing 1λèλ1šÂ¨¨¨øPO: Try it online;

          - Infinite list λλ1šÂ¨¨¨øPO: Try it online. (Note that 2 bytes are saved here instead of 1, because the recursive environment starts with $a(0)=1$ by default.)



          Explanation:



          This instead implements the formula found by @xnor for his Python answer like this:
          $a(n) = sum_k=2^n-1(a(k)cdot a(n-2-k))$



          $a(-1) = a(0) = a(1) = a(2) = 1$





           λ # Create a recursive environment,
          £ # to output the first (implicit) input amount of results after we're done
          1 # Start this recursive list with 1, thus a(0)=1
          # Within the recursive environment, do the following:
          λ # Push the list of values in the range [a(0),a(n)]
          1š # Prepend 1 in front of this list
          Â # Bifurcate the list (short for Duplicate & Reverse copy)
          ¨¨¨ # Remove (up to) the last three value in this reversed list
          ø # Create pairs with the list we bifurcated earlier
          # (which will automatically remove any trailing items of the longer list)
          P # Get the product of each pair (which will result in 1 for an empty list)
          O # And sum the entire list
          # (afterwards the resulting list is output implicitly)





          share|improve this answer












          $endgroup$









          • 1




            $begingroup$
            Interesting that this can solve a(1200) in 40 second on tio, while other recursive approaches time out for numbers n than 100...
            $endgroup$
            – Stewie Griffin
            Sep 20 at 10:32






          • 1




            $begingroup$
            I also made (but didn't publish) a recursive version. It's 13 bytes for the first n terms, or 11 bytes for an infinite list. Special-casing a(n-1) costs a lot of bytes and isn't needed (see for example xnor's formula).
            $endgroup$
            – Grimmy
            Sep 20 at 11:00










          • $begingroup$
            @Grimy Do you mind if I add your recursive solutions to my answer (crediting you of course)? I will leave my original answer as well. But it's nice to see the differences between the original formula and xnor's byte-saving formula. :)
            $endgroup$
            – Kevin Cruijssen
            Sep 20 at 11:47






          • 1




            $begingroup$
            Sure, that's fine!
            $endgroup$
            – Grimmy
            Sep 20 at 11:50










          • $begingroup$
            @StewieGriffin Yeah, I was also impressed by the speed of these recursive infinite functions. Maybe one of Elixir's strengths, and definitely due to the builtin lazy-loading. It calculates n=100 in 0.65 seconds, but when I disable lazy-loading, it will time out after 60 seconds instead, even for n=25.
            $endgroup$
            – Kevin Cruijssen
            Sep 20 at 11:53


















          5

















          $begingroup$


          Python 3, 59 bytes



          really inefficient, a(13) doesn't finish on TIO.



          a=lambda n,k=2:n<4or(n-k<2)*a(n-1)or a(k)*a(n-k-2)+a(n,k+1)


          Try it online!






          share|improve this answer










          $endgroup$





















            3

















            $begingroup$


            Jelly, 17 bytes



            1WṪ;+¥×Uṫ3SƲ;@Ʋ⁸¡


            Try it online!



            A monadic link taking the zero-indexed $n$ and returning the list of generalized Catalan numbers from $0$ to $n$.






            share|improve this answer










            $endgroup$





















              2

















              $begingroup$


              Haskell, 76 bytes





              1:1:1:f[1,1,1]
              f(x:z)|y<-x+sum(zipWith(*)(init$init z)$reverse z)=y:f(y:x:z)


              Try it online!






              share|improve this answer










              $endgroup$





















                2

















                $begingroup$


                APL (Dyalog Extended), 34 bytesSBCS





                -2 thanks to dzaima.



                Anonymous prefix lambda.



                ⍵≤3:1⋄+/(∇⍵-1),⍵(-×⍥∇¯2+⊢)¨4…⍵


                Try it online!






                share|improve this answer












                $endgroup$













                • $begingroup$
                  @dzaima Thanks. TFW someone knows my language better than me :-)
                  $endgroup$
                  – Adám
                  Sep 19 at 13:59


















                2

















                $begingroup$


                Japt, 19 17 16 bytes



                Outputs the nth term, 1-indexed.



                @Zí*Zz2)Ťx}g4Æ1


                Try it



                @Zí*Zz2)Ťx}g4Æ1 :Implicit input of integer U
                @ :Function taking an array as an argument via parameter Z
                Zí : Interleave Z with
                Zz2 : Z rotated clockwise by 180 degrees (simply reversing would be a bye shorter but would modify the original array)
                * : Reduce each pair by multiplcation
                ) : End interleave
                Å : Slice off the first element
                ¤ : Slice off the first 2 elements
                x : Reduce by addition
                } :End function
                g :Pass the following as Z, push the result back to it and repeat until it has length U
                4Æ1 :Map the range [0,4) to 1s
                :Implicit output of the last element





                share|improve this answer












                $endgroup$





















                  1

















                  $begingroup$


                  Haskell, 65 bytes





                  f a|a<4=1|z<-g[2..a]=sum$zipWith(*)z$reverse(1:g[0..a-4])
                  g=map f


                  Try it online!



                  You can use either f to get a single element of a sequence, or pass a list of values to g and get all the indexes for that list.






                  share|improve this answer












                  $endgroup$





















                    1

















                    $begingroup$


                    Forth (gforth), 99 81 bytes





                    : f recursive dup 4 > if 0 over 3 do over 1- i - f i f * + loop else 1 then nip ;


                    Try it online!



                    Output is nth term and input is 1-indexed



                    Edit: Saved 17 bytes by switching to xnor's formula. Saved another 1 byte by using 1-indexed



                    Code Explanation



                    : f start a new word definition
                    recursive mark that this word will be recursive
                    dup 4 > duplicate the input and check if it is greater than 4
                    if if it is:
                    0 over create an accumulator and copy n to top of stack
                    3 do start counted loop from 3 to n-1
                    over 1- i - f recursively calculate f(n-1-i)
                    i f recursively calculate f(i)
                    * + multiply results and add to accumulator
                    loop end the counted loop
                    else otherwise, if n < 5
                    1 put 1 on the stack
                    then end the if block
                    nip drop n from the stack
                    ; end the word definition





                    share|improve this answer












                    $endgroup$





















                      1

















                      $begingroup$


                      Charcoal, 26 bytes



                      F⁵⊞υ¹FN⊞υΣ✂E⮌υ×κ§υλ³→I§υ±⁴


                      Try it online! Link is to verbose version of code. Prints the 0-indexed nth number, although it calculates using 1-indexing internally. Explanation:



                      F⁵⊞υ¹


                      Start with a[0] = a[1] = a[2] = a[3] = a[4] = 1. Yes, this is 1-indexed, but then with an extra zeroth value. That's code golf for you.



                      FN


                      Calculate an additional n terms. This is overkill, but it makes finding the desired term easier when n<5.



                      ⊞υΣ✂E⮌υ×κ§υλ³


                      For each term, compute the next term as the sum of the terms so far termwise multiplied by the reverse of the terms so far, excluding three terms.






                      This is a no-op used to trick Charcoal into parsing the 2-argument form of Slice, otherwise I would have to use a less golfy way of removing three terms.



                      I§υ±⁴


                      Output the 4th last term.






                      share|improve this answer










                      $endgroup$





















                        1

















                        $begingroup$


                        Pyth, 30 bytes



                        J*4]1VQ=+J+eJsPP*M.t,PJ_PJ0;<J


                        Try it online!



                        Returns the first $n$ elements of the sequence.



                        J*4]1VQ=+J+eJsPP*M.t,PJ_PJ0;<JQ # Full program, last Q = input (implicitly added)
                        J*4]1 # J = 4 * [1] (=[1,1,1,1])
                        VQ # for N in range(Q):
                        =+J # J +=
                        +eJ # J[-1] +
                        s # sum( )
                        *M # map(__operator_mul, )
                        .t 0 # transpose( , pad=0)
                        , # [ , ]
                        PJ # J[:-1]
                        _PJ # J[1::-1]
                        <JQ # J[::Q]


                        Alternative: Replace < with @ to return the $n$-th element of the sequence, 0-indexed.






                        share|improve this answer










                        $endgroup$





















                          1

















                          $begingroup$


                          Ruby, 42 41 bytes





                          f=->nn<4?1:(4..n).sum


                          Try it online!



                          1-indexed (to save 1 byte)






                          share|improve this answer












                          $endgroup$





















                            1

















                            $begingroup$


                            Octave, 73 bytes





                            g=(1:4).^0;for(i=3:(n=input('')))g(i+2)=g(4:i+1)*g(i-(2:i-1))';end;g(end)


                            Try it online!



                            -2 bytes thanks to Stewie Griffin. Once more, the imperative approach wins over the functional recursive approach. That one is shown below.




                            Octave, 75 bytes





                            f(f=@(a)@(n)@()sum(arrayfun(@(k)a(a)(k)*a(a)(n-2-k),2:n-1)),12-(n>3)())


                            Try it online!



                            Captcha wanted to verify I was a human when posting this. To be honest, I'm not so sure.






                            share|improve this answer












                            $endgroup$













                            • $begingroup$
                              I can't see any obvious ways to shorten the loop approach... It looks pretty well golfed! Also, it's not often I see zero-based indexing in Octave :)
                              $endgroup$
                              – Stewie Griffin
                              Sep 20 at 12:50











                            • $begingroup$
                              @StewieGriffin Since the recursion has some offsets it doesn't really matter if you pick zero- or one indexing. I think maybe I could shave some bytes of if I did 2-indexing, but that seemed like cheating. Anyway, your intuition was right - somehow, this was indeed shorter in an anonymous recursive way. I think the main advantage is that it handles creating the four initial values very well because it just returns 1 for n<4.
                              $endgroup$
                              – Sanchises
                              Sep 20 at 13:00






                            • 1




                              $begingroup$
                              @StewieGriffin Of course, good old matrix multiplication. Well done!
                              $endgroup$
                              – Sanchises
                              Sep 22 at 15:49


















                            0

















                            $begingroup$


                            Perl 5 -MList::Util=sum, 61 bytes





                            sub asum a($b+1),mapa($_)*a($b-$_)2..$b


                            Try it online!






                            share|improve this answer










                            $endgroup$





















                              0

















                              $begingroup$


                              C/C++, 70 69 67 bytes



                              -1 bytes thanks to Jonathan.



                              int a(int n)int k=2,s=0;while(++k<n)s+=a(k)*a(n+~k);return s?s:1;


                              Try it online!






                              share|improve this answer












                              $endgroup$













                              • $begingroup$
                                Can a(n-1-k) be a(n+~k)?
                                $endgroup$
                                – Jonathan Frech
                                Sep 21 at 12:00










                              • $begingroup$
                                @JonathanFrech even a(++k)*a(n-k) is likely to work, and it drops further 2 bytes from for. But I smell undefined behavior.
                                $endgroup$
                                – polfosol ఠ_ఠ
                                Sep 21 at 12:25










                              • $begingroup$
                                That appears to be a sequencing issue; most definitely UB.
                                $endgroup$
                                – Jonathan Frech
                                Sep 21 at 18:16












                              Your Answer






                              StackExchange.ifUsing("editor", function ()
                              StackExchange.using("externalEditor", function ()
                              StackExchange.using("snippets", function ()
                              StackExchange.snippets.init();
                              );
                              );
                              , "code-snippets");

                              StackExchange.ready(function()
                              var channelOptions =
                              tags: "".split(" "),
                              id: "200"
                              ;
                              initTagRenderer("".split(" "), "".split(" "), channelOptions);

                              StackExchange.using("externalEditor", function()
                              // Have to fire editor after snippets, if snippets enabled
                              if (StackExchange.settings.snippets.snippetsEnabled)
                              StackExchange.using("snippets", function()
                              createEditor();
                              );

                              else
                              createEditor();

                              );

                              function createEditor()
                              StackExchange.prepareEditor(
                              heartbeatType: 'answer',
                              autoActivateHeartbeat: false,
                              convertImagesToLinks: false,
                              noModals: true,
                              showLowRepImageUploadWarning: true,
                              reputationToPostImages: null,
                              bindNavPrevention: true,
                              postfix: "",
                              imageUploader:
                              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                              allowUrls: true
                              ,
                              onDemand: true,
                              discardSelector: ".discard-answer"
                              ,immediatelyShowMarkdownHelp:true
                              );



                              );














                              draft saved

                              draft discarded
















                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f193170%2f1-2-4-8-16-33%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown


























                              20 Answers
                              20






                              active

                              oldest

                              votes








                              20 Answers
                              20






                              active

                              oldest

                              votes









                              active

                              oldest

                              votes






                              active

                              oldest

                              votes









                              22

















                              $begingroup$


                              Python, 51 bytes





                              f=lambda n,k=2:n<3or k<n and f(k)*f(n-k-2)+f(n,k+1)


                              Try it online!



                              Simplifies the formula a bit:



                              $$a(n) = sum_k=2^n-1 a(k)cdot a(n-2-k)$$



                              $$ a(-1) = a(0)= a(1)= a(2) = 1$$






                              share|improve this answer












                              $endgroup$









                              • 8




                                $begingroup$
                                Congrats on the 100k!!
                                $endgroup$
                                – Stewie Griffin
                                Sep 19 at 17:39










                              • $begingroup$
                                Since I also arrived to this solution independently, I must say that the path towards it is a bit bumpy...
                                $endgroup$
                                – Erik the Outgolfer
                                Sep 19 at 23:43















                              22

















                              $begingroup$


                              Python, 51 bytes





                              f=lambda n,k=2:n<3or k<n and f(k)*f(n-k-2)+f(n,k+1)


                              Try it online!



                              Simplifies the formula a bit:



                              $$a(n) = sum_k=2^n-1 a(k)cdot a(n-2-k)$$



                              $$ a(-1) = a(0)= a(1)= a(2) = 1$$






                              share|improve this answer












                              $endgroup$









                              • 8




                                $begingroup$
                                Congrats on the 100k!!
                                $endgroup$
                                – Stewie Griffin
                                Sep 19 at 17:39










                              • $begingroup$
                                Since I also arrived to this solution independently, I must say that the path towards it is a bit bumpy...
                                $endgroup$
                                – Erik the Outgolfer
                                Sep 19 at 23:43













                              22















                              22











                              22







                              $begingroup$


                              Python, 51 bytes





                              f=lambda n,k=2:n<3or k<n and f(k)*f(n-k-2)+f(n,k+1)


                              Try it online!



                              Simplifies the formula a bit:



                              $$a(n) = sum_k=2^n-1 a(k)cdot a(n-2-k)$$



                              $$ a(-1) = a(0)= a(1)= a(2) = 1$$






                              share|improve this answer












                              $endgroup$




                              Python, 51 bytes





                              f=lambda n,k=2:n<3or k<n and f(k)*f(n-k-2)+f(n,k+1)


                              Try it online!



                              Simplifies the formula a bit:



                              $$a(n) = sum_k=2^n-1 a(k)cdot a(n-2-k)$$



                              $$ a(-1) = a(0)= a(1)= a(2) = 1$$







                              share|improve this answer















                              share|improve this answer




                              share|improve this answer








                              edited Sep 19 at 14:27

























                              answered Sep 19 at 14:14









                              xnorxnor

                              112k20 gold badges213 silver badges482 bronze badges




                              112k20 gold badges213 silver badges482 bronze badges










                              • 8




                                $begingroup$
                                Congrats on the 100k!!
                                $endgroup$
                                – Stewie Griffin
                                Sep 19 at 17:39










                              • $begingroup$
                                Since I also arrived to this solution independently, I must say that the path towards it is a bit bumpy...
                                $endgroup$
                                – Erik the Outgolfer
                                Sep 19 at 23:43












                              • 8




                                $begingroup$
                                Congrats on the 100k!!
                                $endgroup$
                                – Stewie Griffin
                                Sep 19 at 17:39










                              • $begingroup$
                                Since I also arrived to this solution independently, I must say that the path towards it is a bit bumpy...
                                $endgroup$
                                – Erik the Outgolfer
                                Sep 19 at 23:43







                              8




                              8




                              $begingroup$
                              Congrats on the 100k!!
                              $endgroup$
                              – Stewie Griffin
                              Sep 19 at 17:39




                              $begingroup$
                              Congrats on the 100k!!
                              $endgroup$
                              – Stewie Griffin
                              Sep 19 at 17:39












                              $begingroup$
                              Since I also arrived to this solution independently, I must say that the path towards it is a bit bumpy...
                              $endgroup$
                              – Erik the Outgolfer
                              Sep 19 at 23:43




                              $begingroup$
                              Since I also arrived to this solution independently, I must say that the path towards it is a bit bumpy...
                              $endgroup$
                              – Erik the Outgolfer
                              Sep 19 at 23:43













                              10

















                              $begingroup$


                              Perl 6, 44 bytes





                              1,1,1,1,sum @_[2..*]Z*@_[@_-4...0,0]...*


                              Try it online!



                              Anonymous code block that returns a lazy infinite sequence of values. This pretty much implements the sequence as described, with the shortcut that it zip multiplies all the elements so far after the second element with the reverse of the list starting from the fourth element and adding an extra 1 at the end.



                              Explanation:



                               # Anonymous code block
                              ...* # Create an infinite sequence
                              1,1,1,1, # Starting with four 1s
                              # Where each new element is:
                              sum # The sum of
                              @_[2..*] # The second element onwards
                              Z* # Zip multiplied with
                              @_[@_-4...0 ] # The fourth last element backwards
                              ,0 # And 1





                              share|improve this answer










                              $endgroup$


















                                10

















                                $begingroup$


                                Perl 6, 44 bytes





                                1,1,1,1,sum @_[2..*]Z*@_[@_-4...0,0]...*


                                Try it online!



                                Anonymous code block that returns a lazy infinite sequence of values. This pretty much implements the sequence as described, with the shortcut that it zip multiplies all the elements so far after the second element with the reverse of the list starting from the fourth element and adding an extra 1 at the end.



                                Explanation:



                                 # Anonymous code block
                                ...* # Create an infinite sequence
                                1,1,1,1, # Starting with four 1s
                                # Where each new element is:
                                sum # The sum of
                                @_[2..*] # The second element onwards
                                Z* # Zip multiplied with
                                @_[@_-4...0 ] # The fourth last element backwards
                                ,0 # And 1





                                share|improve this answer










                                $endgroup$
















                                  10















                                  10











                                  10







                                  $begingroup$


                                  Perl 6, 44 bytes





                                  1,1,1,1,sum @_[2..*]Z*@_[@_-4...0,0]...*


                                  Try it online!



                                  Anonymous code block that returns a lazy infinite sequence of values. This pretty much implements the sequence as described, with the shortcut that it zip multiplies all the elements so far after the second element with the reverse of the list starting from the fourth element and adding an extra 1 at the end.



                                  Explanation:



                                   # Anonymous code block
                                  ...* # Create an infinite sequence
                                  1,1,1,1, # Starting with four 1s
                                  # Where each new element is:
                                  sum # The sum of
                                  @_[2..*] # The second element onwards
                                  Z* # Zip multiplied with
                                  @_[@_-4...0 ] # The fourth last element backwards
                                  ,0 # And 1





                                  share|improve this answer










                                  $endgroup$




                                  Perl 6, 44 bytes





                                  1,1,1,1,sum @_[2..*]Z*@_[@_-4...0,0]...*


                                  Try it online!



                                  Anonymous code block that returns a lazy infinite sequence of values. This pretty much implements the sequence as described, with the shortcut that it zip multiplies all the elements so far after the second element with the reverse of the list starting from the fourth element and adding an extra 1 at the end.



                                  Explanation:



                                   # Anonymous code block
                                  ...* # Create an infinite sequence
                                  1,1,1,1, # Starting with four 1s
                                  # Where each new element is:
                                  sum # The sum of
                                  @_[2..*] # The second element onwards
                                  Z* # Zip multiplied with
                                  @_[@_-4...0 ] # The fourth last element backwards
                                  ,0 # And 1






                                  share|improve this answer













                                  share|improve this answer




                                  share|improve this answer










                                  answered Sep 19 at 13:11









                                  Jo KingJo King

                                  36k4 gold badges78 silver badges151 bronze badges




                                  36k4 gold badges78 silver badges151 bronze badges
























                                      10

















                                      $begingroup$


                                      05AB1E, 14 13 11 bytes



                                      $ƒˆ¯Âø¨¨¨PO


                                      Try it online!



                                      Outputs the nth element, 0-indexed.



                                      $ # push 1 and the input
                                      ƒ # repeat (input+1) times
                                      ˆ # add the top of the stack (initially 1) to the global array
                                      ¯ # push the global array
                                      Â # and a reversed copy of it
                                      ø # zip the two together, giving a list of pairs
                                      ¨¨¨ # drop the last 3 pairs
                                      P # take the product of each pair (or 1 if the list is empty)
                                      O # take the sum of those products
                                      # after the last iteration, this is implicitly output;
                                      # otherwise, it's added to the global array by the next iteration





                                      share|improve this answer












                                      $endgroup$


















                                        10

















                                        $begingroup$


                                        05AB1E, 14 13 11 bytes



                                        $ƒˆ¯Âø¨¨¨PO


                                        Try it online!



                                        Outputs the nth element, 0-indexed.



                                        $ # push 1 and the input
                                        ƒ # repeat (input+1) times
                                        ˆ # add the top of the stack (initially 1) to the global array
                                        ¯ # push the global array
                                        Â # and a reversed copy of it
                                        ø # zip the two together, giving a list of pairs
                                        ¨¨¨ # drop the last 3 pairs
                                        P # take the product of each pair (or 1 if the list is empty)
                                        O # take the sum of those products
                                        # after the last iteration, this is implicitly output;
                                        # otherwise, it's added to the global array by the next iteration





                                        share|improve this answer












                                        $endgroup$
















                                          10















                                          10











                                          10







                                          $begingroup$


                                          05AB1E, 14 13 11 bytes



                                          $ƒˆ¯Âø¨¨¨PO


                                          Try it online!



                                          Outputs the nth element, 0-indexed.



                                          $ # push 1 and the input
                                          ƒ # repeat (input+1) times
                                          ˆ # add the top of the stack (initially 1) to the global array
                                          ¯ # push the global array
                                          Â # and a reversed copy of it
                                          ø # zip the two together, giving a list of pairs
                                          ¨¨¨ # drop the last 3 pairs
                                          P # take the product of each pair (or 1 if the list is empty)
                                          O # take the sum of those products
                                          # after the last iteration, this is implicitly output;
                                          # otherwise, it's added to the global array by the next iteration





                                          share|improve this answer












                                          $endgroup$




                                          05AB1E, 14 13 11 bytes



                                          $ƒˆ¯Âø¨¨¨PO


                                          Try it online!



                                          Outputs the nth element, 0-indexed.



                                          $ # push 1 and the input
                                          ƒ # repeat (input+1) times
                                          ˆ # add the top of the stack (initially 1) to the global array
                                          ¯ # push the global array
                                          Â # and a reversed copy of it
                                          ø # zip the two together, giving a list of pairs
                                          ¨¨¨ # drop the last 3 pairs
                                          P # take the product of each pair (or 1 if the list is empty)
                                          O # take the sum of those products
                                          # after the last iteration, this is implicitly output;
                                          # otherwise, it's added to the global array by the next iteration






                                          share|improve this answer















                                          share|improve this answer




                                          share|improve this answer








                                          edited Sep 19 at 14:05

























                                          answered Sep 19 at 13:53









                                          GrimmyGrimmy

                                          9,84619 silver badges43 bronze badges




                                          9,84619 silver badges43 bronze badges
























                                              7

















                                              $begingroup$

                                              JavaScript (ES6), 42 bytes



                                              A port of xnor's solution.



                                              0-indexed.





                                              f=(n,k=2)=>n<3||k<n&&f(k)*f(n+~++k)+f(n,k)


                                              Try it online!




                                              JavaScript (ES6),  83  75 bytes



                                              A faster, less recursive, but significantly longer solution.



                                              0-indexed.





                                              f=(n,i,a=[p=1])=>a[n]||f(n,-~i,[...a,p+=(h=k=>k<i&&a[k]*a[i-++k]+h(k))(2)])


                                              Try it online!






                                              share|improve this answer












                                              $endgroup$


















                                                7

















                                                $begingroup$

                                                JavaScript (ES6), 42 bytes



                                                A port of xnor's solution.



                                                0-indexed.





                                                f=(n,k=2)=>n<3||k<n&&f(k)*f(n+~++k)+f(n,k)


                                                Try it online!




                                                JavaScript (ES6),  83  75 bytes



                                                A faster, less recursive, but significantly longer solution.



                                                0-indexed.





                                                f=(n,i,a=[p=1])=>a[n]||f(n,-~i,[...a,p+=(h=k=>k<i&&a[k]*a[i-++k]+h(k))(2)])


                                                Try it online!






                                                share|improve this answer












                                                $endgroup$
















                                                  7















                                                  7











                                                  7







                                                  $begingroup$

                                                  JavaScript (ES6), 42 bytes



                                                  A port of xnor's solution.



                                                  0-indexed.





                                                  f=(n,k=2)=>n<3||k<n&&f(k)*f(n+~++k)+f(n,k)


                                                  Try it online!




                                                  JavaScript (ES6),  83  75 bytes



                                                  A faster, less recursive, but significantly longer solution.



                                                  0-indexed.





                                                  f=(n,i,a=[p=1])=>a[n]||f(n,-~i,[...a,p+=(h=k=>k<i&&a[k]*a[i-++k]+h(k))(2)])


                                                  Try it online!






                                                  share|improve this answer












                                                  $endgroup$



                                                  JavaScript (ES6), 42 bytes



                                                  A port of xnor's solution.



                                                  0-indexed.





                                                  f=(n,k=2)=>n<3||k<n&&f(k)*f(n+~++k)+f(n,k)


                                                  Try it online!




                                                  JavaScript (ES6),  83  75 bytes



                                                  A faster, less recursive, but significantly longer solution.



                                                  0-indexed.





                                                  f=(n,i,a=[p=1])=>a[n]||f(n,-~i,[...a,p+=(h=k=>k<i&&a[k]*a[i-++k]+h(k))(2)])


                                                  Try it online!







                                                  share|improve this answer















                                                  share|improve this answer




                                                  share|improve this answer








                                                  edited Sep 19 at 15:04

























                                                  answered Sep 19 at 12:41









                                                  ArnauldArnauld

                                                  104k7 gold badges115 silver badges398 bronze badges




                                                  104k7 gold badges115 silver badges398 bronze badges
























                                                      7

















                                                      $begingroup$

                                                      Haskell, 49 43 39 bytes



                                                      a n=max(sum[a k*a(n-2-k)|k<-[2..n-1]])1 


                                                      Try it online!



                                                      For n<3 the sum is 0, so max ... 1 raises it to 1.



                                                      Edit: -6 bytes thanks to @Jo King.






                                                      share|improve this answer












                                                      $endgroup$


















                                                        7

















                                                        $begingroup$

                                                        Haskell, 49 43 39 bytes



                                                        a n=max(sum[a k*a(n-2-k)|k<-[2..n-1]])1 


                                                        Try it online!



                                                        For n<3 the sum is 0, so max ... 1 raises it to 1.



                                                        Edit: -6 bytes thanks to @Jo King.






                                                        share|improve this answer












                                                        $endgroup$
















                                                          7















                                                          7











                                                          7







                                                          $begingroup$

                                                          Haskell, 49 43 39 bytes



                                                          a n=max(sum[a k*a(n-2-k)|k<-[2..n-1]])1 


                                                          Try it online!



                                                          For n<3 the sum is 0, so max ... 1 raises it to 1.



                                                          Edit: -6 bytes thanks to @Jo King.






                                                          share|improve this answer












                                                          $endgroup$



                                                          Haskell, 49 43 39 bytes



                                                          a n=max(sum[a k*a(n-2-k)|k<-[2..n-1]])1 


                                                          Try it online!



                                                          For n<3 the sum is 0, so max ... 1 raises it to 1.



                                                          Edit: -6 bytes thanks to @Jo King.







                                                          share|improve this answer















                                                          share|improve this answer




                                                          share|improve this answer








                                                          edited Sep 20 at 13:25

























                                                          answered Sep 19 at 17:33









                                                          niminimi

                                                          34.5k3 gold badges28 silver badges92 bronze badges




                                                          34.5k3 gold badges28 silver badges92 bronze badges
























                                                              6

















                                                              $begingroup$


                                                              Wolfram Language (Mathematica), 36 bytes



                                                              Sum[#0@i#0[#-i-1],i,3,#-1]/. 0->1&


                                                              Try it online!



                                                              1-indexed.



                                                              The 2-indexed sequence is 4 bytes shorter: Sum[#0@i#0[#-i],i,#-4]/. 0->1&.
                                                              Try it online!






                                                              share|improve this answer










                                                              $endgroup$









                                                              • 2




                                                                $begingroup$
                                                                Impressive that this is shorter than the built in CatalanNumber !
                                                                $endgroup$
                                                                – erfink
                                                                Sep 20 at 22:20















                                                              6

















                                                              $begingroup$


                                                              Wolfram Language (Mathematica), 36 bytes



                                                              Sum[#0@i#0[#-i-1],i,3,#-1]/. 0->1&


                                                              Try it online!



                                                              1-indexed.



                                                              The 2-indexed sequence is 4 bytes shorter: Sum[#0@i#0[#-i],i,#-4]/. 0->1&.
                                                              Try it online!






                                                              share|improve this answer










                                                              $endgroup$









                                                              • 2




                                                                $begingroup$
                                                                Impressive that this is shorter than the built in CatalanNumber !
                                                                $endgroup$
                                                                – erfink
                                                                Sep 20 at 22:20













                                                              6















                                                              6











                                                              6







                                                              $begingroup$


                                                              Wolfram Language (Mathematica), 36 bytes



                                                              Sum[#0@i#0[#-i-1],i,3,#-1]/. 0->1&


                                                              Try it online!



                                                              1-indexed.



                                                              The 2-indexed sequence is 4 bytes shorter: Sum[#0@i#0[#-i],i,#-4]/. 0->1&.
                                                              Try it online!






                                                              share|improve this answer










                                                              $endgroup$




                                                              Wolfram Language (Mathematica), 36 bytes



                                                              Sum[#0@i#0[#-i-1],i,3,#-1]/. 0->1&


                                                              Try it online!



                                                              1-indexed.



                                                              The 2-indexed sequence is 4 bytes shorter: Sum[#0@i#0[#-i],i,#-4]/. 0->1&.
                                                              Try it online!







                                                              share|improve this answer













                                                              share|improve this answer




                                                              share|improve this answer










                                                              answered Sep 19 at 20:34









                                                              attinatattinat

                                                              3,4253 silver badges11 bronze badges




                                                              3,4253 silver badges11 bronze badges










                                                              • 2




                                                                $begingroup$
                                                                Impressive that this is shorter than the built in CatalanNumber !
                                                                $endgroup$
                                                                – erfink
                                                                Sep 20 at 22:20












                                                              • 2




                                                                $begingroup$
                                                                Impressive that this is shorter than the built in CatalanNumber !
                                                                $endgroup$
                                                                – erfink
                                                                Sep 20 at 22:20







                                                              2




                                                              2




                                                              $begingroup$
                                                              Impressive that this is shorter than the built in CatalanNumber !
                                                              $endgroup$
                                                              – erfink
                                                              Sep 20 at 22:20




                                                              $begingroup$
                                                              Impressive that this is shorter than the built in CatalanNumber !
                                                              $endgroup$
                                                              – erfink
                                                              Sep 20 at 22:20











                                                              6

















                                                              $begingroup$


                                                              05AB1E, 17 13 bytes



                                                              4Å1λ£₁λ¨Â¦¦s¦¦*O+


                                                              Not shorter than the existing 05AB1E answer, but I wanted to try the recursive functionality of the new 05AB1E version as practice for myself. Could perhaps be golfed by a few bytes. EDIT: And it indeed can, see the recursive version of @Grimy's 05AB1E answer below, which is 13 bytes.



                                                              Outputs the first $n$ items: Try it online.



                                                              Could be changed to the 0-based $n$'th item when replacing £ with è: Try it online;

                                                              or an infinite list by removing £: Try it online.



                                                              Explanation:



                                                              This implements the formula used in the challenge description like this:
                                                              $a(n)= a(n-1) + sum_k=2^n-1(a(k)cdot a(n-1-k))$



                                                              $a(0)=a(1)=a(2)=a(3)=1$





                                                               λ # Create a recursive environment,
                                                              £ # to output the first (implicit) input amount of results after we're done
                                                              4Å1 # Start this recursive list with [1,1,1,1], thus a(0)=a(1)=a(2)=a(3)=1
                                                              # Within the recursive environment, do the following:
                                                              λ # Push the list of values in the range [a(0),a(n)]
                                                              ¨ # Remove the last one to make the range [a(0),a(n-1)]
                                                              Â # Bifurcate this list (short for Duplicate & Reverse copy)
                                                              ¦¦ # Remove the first two items of the reversed list,
                                                              # so we'll have a list with the values in the range [a(n-3),a(0)]
                                                              s # Swap to get the [a(0),a(n-1)] list again
                                                              ¦¦ # Remove the first two items of this list as well,
                                                              # so we'll have a list with the values in the range [a(2),a(n-1)]
                                                              * # Multiply the values at the same indices in both lists,
                                                              # so we'll have a list with the values [a(n-3)*a(2),...,a(0)*a(n-1)]
                                                              O # Take the sum of this list
                                                              ₁ + # And add it to the a(n-1)'th value
                                                              # (afterwards the resulting list is output implicitly)





                                                              13 bytes version of @Grimy (make sure to upvote his answer if you haven't yet!):



                                                              1λ£λ1šÂ¨¨¨øPO


                                                              Outputs the first $n$ items: Try it online.



                                                              Can again be changed to 0-based indexing or an infinite list instead:

                                                              - (0-based) indexing 1λèλ1šÂ¨¨¨øPO: Try it online;

                                                              - Infinite list λλ1šÂ¨¨¨øPO: Try it online. (Note that 2 bytes are saved here instead of 1, because the recursive environment starts with $a(0)=1$ by default.)



                                                              Explanation:



                                                              This instead implements the formula found by @xnor for his Python answer like this:
                                                              $a(n) = sum_k=2^n-1(a(k)cdot a(n-2-k))$



                                                              $a(-1) = a(0) = a(1) = a(2) = 1$





                                                               λ # Create a recursive environment,
                                                              £ # to output the first (implicit) input amount of results after we're done
                                                              1 # Start this recursive list with 1, thus a(0)=1
                                                              # Within the recursive environment, do the following:
                                                              λ # Push the list of values in the range [a(0),a(n)]
                                                              1š # Prepend 1 in front of this list
                                                              Â # Bifurcate the list (short for Duplicate & Reverse copy)
                                                              ¨¨¨ # Remove (up to) the last three value in this reversed list
                                                              ø # Create pairs with the list we bifurcated earlier
                                                              # (which will automatically remove any trailing items of the longer list)
                                                              P # Get the product of each pair (which will result in 1 for an empty list)
                                                              O # And sum the entire list
                                                              # (afterwards the resulting list is output implicitly)





                                                              share|improve this answer












                                                              $endgroup$









                                                              • 1




                                                                $begingroup$
                                                                Interesting that this can solve a(1200) in 40 second on tio, while other recursive approaches time out for numbers n than 100...
                                                                $endgroup$
                                                                – Stewie Griffin
                                                                Sep 20 at 10:32






                                                              • 1




                                                                $begingroup$
                                                                I also made (but didn't publish) a recursive version. It's 13 bytes for the first n terms, or 11 bytes for an infinite list. Special-casing a(n-1) costs a lot of bytes and isn't needed (see for example xnor's formula).
                                                                $endgroup$
                                                                – Grimmy
                                                                Sep 20 at 11:00










                                                              • $begingroup$
                                                                @Grimy Do you mind if I add your recursive solutions to my answer (crediting you of course)? I will leave my original answer as well. But it's nice to see the differences between the original formula and xnor's byte-saving formula. :)
                                                                $endgroup$
                                                                – Kevin Cruijssen
                                                                Sep 20 at 11:47






                                                              • 1




                                                                $begingroup$
                                                                Sure, that's fine!
                                                                $endgroup$
                                                                – Grimmy
                                                                Sep 20 at 11:50










                                                              • $begingroup$
                                                                @StewieGriffin Yeah, I was also impressed by the speed of these recursive infinite functions. Maybe one of Elixir's strengths, and definitely due to the builtin lazy-loading. It calculates n=100 in 0.65 seconds, but when I disable lazy-loading, it will time out after 60 seconds instead, even for n=25.
                                                                $endgroup$
                                                                – Kevin Cruijssen
                                                                Sep 20 at 11:53















                                                              6

















                                                              $begingroup$


                                                              05AB1E, 17 13 bytes



                                                              4Å1λ£₁λ¨Â¦¦s¦¦*O+


                                                              Not shorter than the existing 05AB1E answer, but I wanted to try the recursive functionality of the new 05AB1E version as practice for myself. Could perhaps be golfed by a few bytes. EDIT: And it indeed can, see the recursive version of @Grimy's 05AB1E answer below, which is 13 bytes.



                                                              Outputs the first $n$ items: Try it online.



                                                              Could be changed to the 0-based $n$'th item when replacing £ with è: Try it online;

                                                              or an infinite list by removing £: Try it online.



                                                              Explanation:



                                                              This implements the formula used in the challenge description like this:
                                                              $a(n)= a(n-1) + sum_k=2^n-1(a(k)cdot a(n-1-k))$



                                                              $a(0)=a(1)=a(2)=a(3)=1$





                                                               λ # Create a recursive environment,
                                                              £ # to output the first (implicit) input amount of results after we're done
                                                              4Å1 # Start this recursive list with [1,1,1,1], thus a(0)=a(1)=a(2)=a(3)=1
                                                              # Within the recursive environment, do the following:
                                                              λ # Push the list of values in the range [a(0),a(n)]
                                                              ¨ # Remove the last one to make the range [a(0),a(n-1)]
                                                              Â # Bifurcate this list (short for Duplicate & Reverse copy)
                                                              ¦¦ # Remove the first two items of the reversed list,
                                                              # so we'll have a list with the values in the range [a(n-3),a(0)]
                                                              s # Swap to get the [a(0),a(n-1)] list again
                                                              ¦¦ # Remove the first two items of this list as well,
                                                              # so we'll have a list with the values in the range [a(2),a(n-1)]
                                                              * # Multiply the values at the same indices in both lists,
                                                              # so we'll have a list with the values [a(n-3)*a(2),...,a(0)*a(n-1)]
                                                              O # Take the sum of this list
                                                              ₁ + # And add it to the a(n-1)'th value
                                                              # (afterwards the resulting list is output implicitly)





                                                              13 bytes version of @Grimy (make sure to upvote his answer if you haven't yet!):



                                                              1λ£λ1šÂ¨¨¨øPO


                                                              Outputs the first $n$ items: Try it online.



                                                              Can again be changed to 0-based indexing or an infinite list instead:

                                                              - (0-based) indexing 1λèλ1šÂ¨¨¨øPO: Try it online;

                                                              - Infinite list λλ1šÂ¨¨¨øPO: Try it online. (Note that 2 bytes are saved here instead of 1, because the recursive environment starts with $a(0)=1$ by default.)



                                                              Explanation:



                                                              This instead implements the formula found by @xnor for his Python answer like this:
                                                              $a(n) = sum_k=2^n-1(a(k)cdot a(n-2-k))$



                                                              $a(-1) = a(0) = a(1) = a(2) = 1$





                                                               λ # Create a recursive environment,
                                                              £ # to output the first (implicit) input amount of results after we're done
                                                              1 # Start this recursive list with 1, thus a(0)=1
                                                              # Within the recursive environment, do the following:
                                                              λ # Push the list of values in the range [a(0),a(n)]
                                                              1š # Prepend 1 in front of this list
                                                              Â # Bifurcate the list (short for Duplicate & Reverse copy)
                                                              ¨¨¨ # Remove (up to) the last three value in this reversed list
                                                              ø # Create pairs with the list we bifurcated earlier
                                                              # (which will automatically remove any trailing items of the longer list)
                                                              P # Get the product of each pair (which will result in 1 for an empty list)
                                                              O # And sum the entire list
                                                              # (afterwards the resulting list is output implicitly)





                                                              share|improve this answer












                                                              $endgroup$









                                                              • 1




                                                                $begingroup$
                                                                Interesting that this can solve a(1200) in 40 second on tio, while other recursive approaches time out for numbers n than 100...
                                                                $endgroup$
                                                                – Stewie Griffin
                                                                Sep 20 at 10:32






                                                              • 1




                                                                $begingroup$
                                                                I also made (but didn't publish) a recursive version. It's 13 bytes for the first n terms, or 11 bytes for an infinite list. Special-casing a(n-1) costs a lot of bytes and isn't needed (see for example xnor's formula).
                                                                $endgroup$
                                                                – Grimmy
                                                                Sep 20 at 11:00










                                                              • $begingroup$
                                                                @Grimy Do you mind if I add your recursive solutions to my answer (crediting you of course)? I will leave my original answer as well. But it's nice to see the differences between the original formula and xnor's byte-saving formula. :)
                                                                $endgroup$
                                                                – Kevin Cruijssen
                                                                Sep 20 at 11:47






                                                              • 1




                                                                $begingroup$
                                                                Sure, that's fine!
                                                                $endgroup$
                                                                – Grimmy
                                                                Sep 20 at 11:50










                                                              • $begingroup$
                                                                @StewieGriffin Yeah, I was also impressed by the speed of these recursive infinite functions. Maybe one of Elixir's strengths, and definitely due to the builtin lazy-loading. It calculates n=100 in 0.65 seconds, but when I disable lazy-loading, it will time out after 60 seconds instead, even for n=25.
                                                                $endgroup$
                                                                – Kevin Cruijssen
                                                                Sep 20 at 11:53













                                                              6















                                                              6











                                                              6







                                                              $begingroup$


                                                              05AB1E, 17 13 bytes



                                                              4Å1λ£₁λ¨Â¦¦s¦¦*O+


                                                              Not shorter than the existing 05AB1E answer, but I wanted to try the recursive functionality of the new 05AB1E version as practice for myself. Could perhaps be golfed by a few bytes. EDIT: And it indeed can, see the recursive version of @Grimy's 05AB1E answer below, which is 13 bytes.



                                                              Outputs the first $n$ items: Try it online.



                                                              Could be changed to the 0-based $n$'th item when replacing £ with è: Try it online;

                                                              or an infinite list by removing £: Try it online.



                                                              Explanation:



                                                              This implements the formula used in the challenge description like this:
                                                              $a(n)= a(n-1) + sum_k=2^n-1(a(k)cdot a(n-1-k))$



                                                              $a(0)=a(1)=a(2)=a(3)=1$





                                                               λ # Create a recursive environment,
                                                              £ # to output the first (implicit) input amount of results after we're done
                                                              4Å1 # Start this recursive list with [1,1,1,1], thus a(0)=a(1)=a(2)=a(3)=1
                                                              # Within the recursive environment, do the following:
                                                              λ # Push the list of values in the range [a(0),a(n)]
                                                              ¨ # Remove the last one to make the range [a(0),a(n-1)]
                                                              Â # Bifurcate this list (short for Duplicate & Reverse copy)
                                                              ¦¦ # Remove the first two items of the reversed list,
                                                              # so we'll have a list with the values in the range [a(n-3),a(0)]
                                                              s # Swap to get the [a(0),a(n-1)] list again
                                                              ¦¦ # Remove the first two items of this list as well,
                                                              # so we'll have a list with the values in the range [a(2),a(n-1)]
                                                              * # Multiply the values at the same indices in both lists,
                                                              # so we'll have a list with the values [a(n-3)*a(2),...,a(0)*a(n-1)]
                                                              O # Take the sum of this list
                                                              ₁ + # And add it to the a(n-1)'th value
                                                              # (afterwards the resulting list is output implicitly)





                                                              13 bytes version of @Grimy (make sure to upvote his answer if you haven't yet!):



                                                              1λ£λ1šÂ¨¨¨øPO


                                                              Outputs the first $n$ items: Try it online.



                                                              Can again be changed to 0-based indexing or an infinite list instead:

                                                              - (0-based) indexing 1λèλ1šÂ¨¨¨øPO: Try it online;

                                                              - Infinite list λλ1šÂ¨¨¨øPO: Try it online. (Note that 2 bytes are saved here instead of 1, because the recursive environment starts with $a(0)=1$ by default.)



                                                              Explanation:



                                                              This instead implements the formula found by @xnor for his Python answer like this:
                                                              $a(n) = sum_k=2^n-1(a(k)cdot a(n-2-k))$



                                                              $a(-1) = a(0) = a(1) = a(2) = 1$





                                                               λ # Create a recursive environment,
                                                              £ # to output the first (implicit) input amount of results after we're done
                                                              1 # Start this recursive list with 1, thus a(0)=1
                                                              # Within the recursive environment, do the following:
                                                              λ # Push the list of values in the range [a(0),a(n)]
                                                              1š # Prepend 1 in front of this list
                                                              Â # Bifurcate the list (short for Duplicate & Reverse copy)
                                                              ¨¨¨ # Remove (up to) the last three value in this reversed list
                                                              ø # Create pairs with the list we bifurcated earlier
                                                              # (which will automatically remove any trailing items of the longer list)
                                                              P # Get the product of each pair (which will result in 1 for an empty list)
                                                              O # And sum the entire list
                                                              # (afterwards the resulting list is output implicitly)





                                                              share|improve this answer












                                                              $endgroup$




                                                              05AB1E, 17 13 bytes



                                                              4Å1λ£₁λ¨Â¦¦s¦¦*O+


                                                              Not shorter than the existing 05AB1E answer, but I wanted to try the recursive functionality of the new 05AB1E version as practice for myself. Could perhaps be golfed by a few bytes. EDIT: And it indeed can, see the recursive version of @Grimy's 05AB1E answer below, which is 13 bytes.



                                                              Outputs the first $n$ items: Try it online.



                                                              Could be changed to the 0-based $n$'th item when replacing £ with è: Try it online;

                                                              or an infinite list by removing £: Try it online.



                                                              Explanation:



                                                              This implements the formula used in the challenge description like this:
                                                              $a(n)= a(n-1) + sum_k=2^n-1(a(k)cdot a(n-1-k))$



                                                              $a(0)=a(1)=a(2)=a(3)=1$





                                                               λ # Create a recursive environment,
                                                              £ # to output the first (implicit) input amount of results after we're done
                                                              4Å1 # Start this recursive list with [1,1,1,1], thus a(0)=a(1)=a(2)=a(3)=1
                                                              # Within the recursive environment, do the following:
                                                              λ # Push the list of values in the range [a(0),a(n)]
                                                              ¨ # Remove the last one to make the range [a(0),a(n-1)]
                                                              Â # Bifurcate this list (short for Duplicate & Reverse copy)
                                                              ¦¦ # Remove the first two items of the reversed list,
                                                              # so we'll have a list with the values in the range [a(n-3),a(0)]
                                                              s # Swap to get the [a(0),a(n-1)] list again
                                                              ¦¦ # Remove the first two items of this list as well,
                                                              # so we'll have a list with the values in the range [a(2),a(n-1)]
                                                              * # Multiply the values at the same indices in both lists,
                                                              # so we'll have a list with the values [a(n-3)*a(2),...,a(0)*a(n-1)]
                                                              O # Take the sum of this list
                                                              ₁ + # And add it to the a(n-1)'th value
                                                              # (afterwards the resulting list is output implicitly)





                                                              13 bytes version of @Grimy (make sure to upvote his answer if you haven't yet!):



                                                              1λ£λ1šÂ¨¨¨øPO


                                                              Outputs the first $n$ items: Try it online.



                                                              Can again be changed to 0-based indexing or an infinite list instead:

                                                              - (0-based) indexing 1λèλ1šÂ¨¨¨øPO: Try it online;

                                                              - Infinite list λλ1šÂ¨¨¨øPO: Try it online. (Note that 2 bytes are saved here instead of 1, because the recursive environment starts with $a(0)=1$ by default.)



                                                              Explanation:



                                                              This instead implements the formula found by @xnor for his Python answer like this:
                                                              $a(n) = sum_k=2^n-1(a(k)cdot a(n-2-k))$



                                                              $a(-1) = a(0) = a(1) = a(2) = 1$





                                                               λ # Create a recursive environment,
                                                              £ # to output the first (implicit) input amount of results after we're done
                                                              1 # Start this recursive list with 1, thus a(0)=1
                                                              # Within the recursive environment, do the following:
                                                              λ # Push the list of values in the range [a(0),a(n)]
                                                              1š # Prepend 1 in front of this list
                                                              Â # Bifurcate the list (short for Duplicate & Reverse copy)
                                                              ¨¨¨ # Remove (up to) the last three value in this reversed list
                                                              ø # Create pairs with the list we bifurcated earlier
                                                              # (which will automatically remove any trailing items of the longer list)
                                                              P # Get the product of each pair (which will result in 1 for an empty list)
                                                              O # And sum the entire list
                                                              # (afterwards the resulting list is output implicitly)






                                                              share|improve this answer















                                                              share|improve this answer




                                                              share|improve this answer








                                                              edited Sep 20 at 12:26

























                                                              answered Sep 20 at 7:53









                                                              Kevin CruijssenKevin Cruijssen

                                                              62.5k7 gold badges89 silver badges257 bronze badges




                                                              62.5k7 gold badges89 silver badges257 bronze badges










                                                              • 1




                                                                $begingroup$
                                                                Interesting that this can solve a(1200) in 40 second on tio, while other recursive approaches time out for numbers n than 100...
                                                                $endgroup$
                                                                – Stewie Griffin
                                                                Sep 20 at 10:32






                                                              • 1




                                                                $begingroup$
                                                                I also made (but didn't publish) a recursive version. It's 13 bytes for the first n terms, or 11 bytes for an infinite list. Special-casing a(n-1) costs a lot of bytes and isn't needed (see for example xnor's formula).
                                                                $endgroup$
                                                                – Grimmy
                                                                Sep 20 at 11:00










                                                              • $begingroup$
                                                                @Grimy Do you mind if I add your recursive solutions to my answer (crediting you of course)? I will leave my original answer as well. But it's nice to see the differences between the original formula and xnor's byte-saving formula. :)
                                                                $endgroup$
                                                                – Kevin Cruijssen
                                                                Sep 20 at 11:47






                                                              • 1




                                                                $begingroup$
                                                                Sure, that's fine!
                                                                $endgroup$
                                                                – Grimmy
                                                                Sep 20 at 11:50










                                                              • $begingroup$
                                                                @StewieGriffin Yeah, I was also impressed by the speed of these recursive infinite functions. Maybe one of Elixir's strengths, and definitely due to the builtin lazy-loading. It calculates n=100 in 0.65 seconds, but when I disable lazy-loading, it will time out after 60 seconds instead, even for n=25.
                                                                $endgroup$
                                                                – Kevin Cruijssen
                                                                Sep 20 at 11:53












                                                              • 1




                                                                $begingroup$
                                                                Interesting that this can solve a(1200) in 40 second on tio, while other recursive approaches time out for numbers n than 100...
                                                                $endgroup$
                                                                – Stewie Griffin
                                                                Sep 20 at 10:32






                                                              • 1




                                                                $begingroup$
                                                                I also made (but didn't publish) a recursive version. It's 13 bytes for the first n terms, or 11 bytes for an infinite list. Special-casing a(n-1) costs a lot of bytes and isn't needed (see for example xnor's formula).
                                                                $endgroup$
                                                                – Grimmy
                                                                Sep 20 at 11:00










                                                              • $begingroup$
                                                                @Grimy Do you mind if I add your recursive solutions to my answer (crediting you of course)? I will leave my original answer as well. But it's nice to see the differences between the original formula and xnor's byte-saving formula. :)
                                                                $endgroup$
                                                                – Kevin Cruijssen
                                                                Sep 20 at 11:47






                                                              • 1




                                                                $begingroup$
                                                                Sure, that's fine!
                                                                $endgroup$
                                                                – Grimmy
                                                                Sep 20 at 11:50










                                                              • $begingroup$
                                                                @StewieGriffin Yeah, I was also impressed by the speed of these recursive infinite functions. Maybe one of Elixir's strengths, and definitely due to the builtin lazy-loading. It calculates n=100 in 0.65 seconds, but when I disable lazy-loading, it will time out after 60 seconds instead, even for n=25.
                                                                $endgroup$
                                                                – Kevin Cruijssen
                                                                Sep 20 at 11:53







                                                              1




                                                              1




                                                              $begingroup$
                                                              Interesting that this can solve a(1200) in 40 second on tio, while other recursive approaches time out for numbers n than 100...
                                                              $endgroup$
                                                              – Stewie Griffin
                                                              Sep 20 at 10:32




                                                              $begingroup$
                                                              Interesting that this can solve a(1200) in 40 second on tio, while other recursive approaches time out for numbers n than 100...
                                                              $endgroup$
                                                              – Stewie Griffin
                                                              Sep 20 at 10:32




                                                              1




                                                              1




                                                              $begingroup$
                                                              I also made (but didn't publish) a recursive version. It's 13 bytes for the first n terms, or 11 bytes for an infinite list. Special-casing a(n-1) costs a lot of bytes and isn't needed (see for example xnor's formula).
                                                              $endgroup$
                                                              – Grimmy
                                                              Sep 20 at 11:00




                                                              $begingroup$
                                                              I also made (but didn't publish) a recursive version. It's 13 bytes for the first n terms, or 11 bytes for an infinite list. Special-casing a(n-1) costs a lot of bytes and isn't needed (see for example xnor's formula).
                                                              $endgroup$
                                                              – Grimmy
                                                              Sep 20 at 11:00












                                                              $begingroup$
                                                              @Grimy Do you mind if I add your recursive solutions to my answer (crediting you of course)? I will leave my original answer as well. But it's nice to see the differences between the original formula and xnor's byte-saving formula. :)
                                                              $endgroup$
                                                              – Kevin Cruijssen
                                                              Sep 20 at 11:47




                                                              $begingroup$
                                                              @Grimy Do you mind if I add your recursive solutions to my answer (crediting you of course)? I will leave my original answer as well. But it's nice to see the differences between the original formula and xnor's byte-saving formula. :)
                                                              $endgroup$
                                                              – Kevin Cruijssen
                                                              Sep 20 at 11:47




                                                              1




                                                              1




                                                              $begingroup$
                                                              Sure, that's fine!
                                                              $endgroup$
                                                              – Grimmy
                                                              Sep 20 at 11:50




                                                              $begingroup$
                                                              Sure, that's fine!
                                                              $endgroup$
                                                              – Grimmy
                                                              Sep 20 at 11:50












                                                              $begingroup$
                                                              @StewieGriffin Yeah, I was also impressed by the speed of these recursive infinite functions. Maybe one of Elixir's strengths, and definitely due to the builtin lazy-loading. It calculates n=100 in 0.65 seconds, but when I disable lazy-loading, it will time out after 60 seconds instead, even for n=25.
                                                              $endgroup$
                                                              – Kevin Cruijssen
                                                              Sep 20 at 11:53




                                                              $begingroup$
                                                              @StewieGriffin Yeah, I was also impressed by the speed of these recursive infinite functions. Maybe one of Elixir's strengths, and definitely due to the builtin lazy-loading. It calculates n=100 in 0.65 seconds, but when I disable lazy-loading, it will time out after 60 seconds instead, even for n=25.
                                                              $endgroup$
                                                              – Kevin Cruijssen
                                                              Sep 20 at 11:53











                                                              5

















                                                              $begingroup$


                                                              Python 3, 59 bytes



                                                              really inefficient, a(13) doesn't finish on TIO.



                                                              a=lambda n,k=2:n<4or(n-k<2)*a(n-1)or a(k)*a(n-k-2)+a(n,k+1)


                                                              Try it online!






                                                              share|improve this answer










                                                              $endgroup$


















                                                                5

















                                                                $begingroup$


                                                                Python 3, 59 bytes



                                                                really inefficient, a(13) doesn't finish on TIO.



                                                                a=lambda n,k=2:n<4or(n-k<2)*a(n-1)or a(k)*a(n-k-2)+a(n,k+1)


                                                                Try it online!






                                                                share|improve this answer










                                                                $endgroup$
















                                                                  5















                                                                  5











                                                                  5







                                                                  $begingroup$


                                                                  Python 3, 59 bytes



                                                                  really inefficient, a(13) doesn't finish on TIO.



                                                                  a=lambda n,k=2:n<4or(n-k<2)*a(n-1)or a(k)*a(n-k-2)+a(n,k+1)


                                                                  Try it online!






                                                                  share|improve this answer










                                                                  $endgroup$




                                                                  Python 3, 59 bytes



                                                                  really inefficient, a(13) doesn't finish on TIO.



                                                                  a=lambda n,k=2:n<4or(n-k<2)*a(n-1)or a(k)*a(n-k-2)+a(n,k+1)


                                                                  Try it online!







                                                                  share|improve this answer













                                                                  share|improve this answer




                                                                  share|improve this answer










                                                                  answered Sep 19 at 13:12









                                                                  ovsovs

                                                                  20.6k2 gold badges13 silver badges66 bronze badges




                                                                  20.6k2 gold badges13 silver badges66 bronze badges
























                                                                      3

















                                                                      $begingroup$


                                                                      Jelly, 17 bytes



                                                                      1WṪ;+¥×Uṫ3SƲ;@Ʋ⁸¡


                                                                      Try it online!



                                                                      A monadic link taking the zero-indexed $n$ and returning the list of generalized Catalan numbers from $0$ to $n$.






                                                                      share|improve this answer










                                                                      $endgroup$


















                                                                        3

















                                                                        $begingroup$


                                                                        Jelly, 17 bytes



                                                                        1WṪ;+¥×Uṫ3SƲ;@Ʋ⁸¡


                                                                        Try it online!



                                                                        A monadic link taking the zero-indexed $n$ and returning the list of generalized Catalan numbers from $0$ to $n$.






                                                                        share|improve this answer










                                                                        $endgroup$
















                                                                          3















                                                                          3











                                                                          3







                                                                          $begingroup$


                                                                          Jelly, 17 bytes



                                                                          1WṪ;+¥×Uṫ3SƲ;@Ʋ⁸¡


                                                                          Try it online!



                                                                          A monadic link taking the zero-indexed $n$ and returning the list of generalized Catalan numbers from $0$ to $n$.






                                                                          share|improve this answer










                                                                          $endgroup$




                                                                          Jelly, 17 bytes



                                                                          1WṪ;+¥×Uṫ3SƲ;@Ʋ⁸¡


                                                                          Try it online!



                                                                          A monadic link taking the zero-indexed $n$ and returning the list of generalized Catalan numbers from $0$ to $n$.







                                                                          share|improve this answer













                                                                          share|improve this answer




                                                                          share|improve this answer










                                                                          answered Sep 19 at 12:51









                                                                          Nick KennedyNick Kennedy

                                                                          8,4721 gold badge9 silver badges24 bronze badges




                                                                          8,4721 gold badge9 silver badges24 bronze badges
























                                                                              2

















                                                                              $begingroup$


                                                                              Haskell, 76 bytes





                                                                              1:1:1:f[1,1,1]
                                                                              f(x:z)|y<-x+sum(zipWith(*)(init$init z)$reverse z)=y:f(y:x:z)


                                                                              Try it online!






                                                                              share|improve this answer










                                                                              $endgroup$


















                                                                                2

















                                                                                $begingroup$


                                                                                Haskell, 76 bytes





                                                                                1:1:1:f[1,1,1]
                                                                                f(x:z)|y<-x+sum(zipWith(*)(init$init z)$reverse z)=y:f(y:x:z)


                                                                                Try it online!






                                                                                share|improve this answer










                                                                                $endgroup$
















                                                                                  2















                                                                                  2











                                                                                  2







                                                                                  $begingroup$


                                                                                  Haskell, 76 bytes





                                                                                  1:1:1:f[1,1,1]
                                                                                  f(x:z)|y<-x+sum(zipWith(*)(init$init z)$reverse z)=y:f(y:x:z)


                                                                                  Try it online!






                                                                                  share|improve this answer










                                                                                  $endgroup$




                                                                                  Haskell, 76 bytes





                                                                                  1:1:1:f[1,1,1]
                                                                                  f(x:z)|y<-x+sum(zipWith(*)(init$init z)$reverse z)=y:f(y:x:z)


                                                                                  Try it online!







                                                                                  share|improve this answer













                                                                                  share|improve this answer




                                                                                  share|improve this answer










                                                                                  answered Sep 19 at 13:20









                                                                                  flawrflawr

                                                                                  39.4k7 gold badges84 silver badges219 bronze badges




                                                                                  39.4k7 gold badges84 silver badges219 bronze badges
























                                                                                      2

















                                                                                      $begingroup$


                                                                                      APL (Dyalog Extended), 34 bytesSBCS





                                                                                      -2 thanks to dzaima.



                                                                                      Anonymous prefix lambda.



                                                                                      ⍵≤3:1⋄+/(∇⍵-1),⍵(-×⍥∇¯2+⊢)¨4…⍵


                                                                                      Try it online!






                                                                                      share|improve this answer












                                                                                      $endgroup$













                                                                                      • $begingroup$
                                                                                        @dzaima Thanks. TFW someone knows my language better than me :-)
                                                                                        $endgroup$
                                                                                        – Adám
                                                                                        Sep 19 at 13:59















                                                                                      2

















                                                                                      $begingroup$


                                                                                      APL (Dyalog Extended), 34 bytesSBCS





                                                                                      -2 thanks to dzaima.



                                                                                      Anonymous prefix lambda.



                                                                                      ⍵≤3:1⋄+/(∇⍵-1),⍵(-×⍥∇¯2+⊢)¨4…⍵


                                                                                      Try it online!






                                                                                      share|improve this answer












                                                                                      $endgroup$













                                                                                      • $begingroup$
                                                                                        @dzaima Thanks. TFW someone knows my language better than me :-)
                                                                                        $endgroup$
                                                                                        – Adám
                                                                                        Sep 19 at 13:59













                                                                                      2















                                                                                      2











                                                                                      2







                                                                                      $begingroup$


                                                                                      APL (Dyalog Extended), 34 bytesSBCS





                                                                                      -2 thanks to dzaima.



                                                                                      Anonymous prefix lambda.



                                                                                      ⍵≤3:1⋄+/(∇⍵-1),⍵(-×⍥∇¯2+⊢)¨4…⍵


                                                                                      Try it online!






                                                                                      share|improve this answer












                                                                                      $endgroup$




                                                                                      APL (Dyalog Extended), 34 bytesSBCS





                                                                                      -2 thanks to dzaima.



                                                                                      Anonymous prefix lambda.



                                                                                      ⍵≤3:1⋄+/(∇⍵-1),⍵(-×⍥∇¯2+⊢)¨4…⍵


                                                                                      Try it online!







                                                                                      share|improve this answer















                                                                                      share|improve this answer




                                                                                      share|improve this answer








                                                                                      edited Sep 19 at 13:59

























                                                                                      answered Sep 19 at 12:40









                                                                                      AdámAdám

                                                                                      39.5k2 gold badges89 silver badges230 bronze badges




                                                                                      39.5k2 gold badges89 silver badges230 bronze badges














                                                                                      • $begingroup$
                                                                                        @dzaima Thanks. TFW someone knows my language better than me :-)
                                                                                        $endgroup$
                                                                                        – Adám
                                                                                        Sep 19 at 13:59
















                                                                                      • $begingroup$
                                                                                        @dzaima Thanks. TFW someone knows my language better than me :-)
                                                                                        $endgroup$
                                                                                        – Adám
                                                                                        Sep 19 at 13:59















                                                                                      $begingroup$
                                                                                      @dzaima Thanks. TFW someone knows my language better than me :-)
                                                                                      $endgroup$
                                                                                      – Adám
                                                                                      Sep 19 at 13:59




                                                                                      $begingroup$
                                                                                      @dzaima Thanks. TFW someone knows my language better than me :-)
                                                                                      $endgroup$
                                                                                      – Adám
                                                                                      Sep 19 at 13:59











                                                                                      2

















                                                                                      $begingroup$


                                                                                      Japt, 19 17 16 bytes



                                                                                      Outputs the nth term, 1-indexed.



                                                                                      @Zí*Zz2)Ťx}g4Æ1


                                                                                      Try it



                                                                                      @Zí*Zz2)Ťx}g4Æ1 :Implicit input of integer U
                                                                                      @ :Function taking an array as an argument via parameter Z
                                                                                      Zí : Interleave Z with
                                                                                      Zz2 : Z rotated clockwise by 180 degrees (simply reversing would be a bye shorter but would modify the original array)
                                                                                      * : Reduce each pair by multiplcation
                                                                                      ) : End interleave
                                                                                      Å : Slice off the first element
                                                                                      ¤ : Slice off the first 2 elements
                                                                                      x : Reduce by addition
                                                                                      } :End function
                                                                                      g :Pass the following as Z, push the result back to it and repeat until it has length U
                                                                                      4Æ1 :Map the range [0,4) to 1s
                                                                                      :Implicit output of the last element





                                                                                      share|improve this answer












                                                                                      $endgroup$


















                                                                                        2

















                                                                                        $begingroup$


                                                                                        Japt, 19 17 16 bytes



                                                                                        Outputs the nth term, 1-indexed.



                                                                                        @Zí*Zz2)Ťx}g4Æ1


                                                                                        Try it



                                                                                        @Zí*Zz2)Ťx}g4Æ1 :Implicit input of integer U
                                                                                        @ :Function taking an array as an argument via parameter Z
                                                                                        Zí : Interleave Z with
                                                                                        Zz2 : Z rotated clockwise by 180 degrees (simply reversing would be a bye shorter but would modify the original array)
                                                                                        * : Reduce each pair by multiplcation
                                                                                        ) : End interleave
                                                                                        Å : Slice off the first element
                                                                                        ¤ : Slice off the first 2 elements
                                                                                        x : Reduce by addition
                                                                                        } :End function
                                                                                        g :Pass the following as Z, push the result back to it and repeat until it has length U
                                                                                        4Æ1 :Map the range [0,4) to 1s
                                                                                        :Implicit output of the last element





                                                                                        share|improve this answer












                                                                                        $endgroup$
















                                                                                          2















                                                                                          2











                                                                                          2







                                                                                          $begingroup$


                                                                                          Japt, 19 17 16 bytes



                                                                                          Outputs the nth term, 1-indexed.



                                                                                          @Zí*Zz2)Ťx}g4Æ1


                                                                                          Try it



                                                                                          @Zí*Zz2)Ťx}g4Æ1 :Implicit input of integer U
                                                                                          @ :Function taking an array as an argument via parameter Z
                                                                                          Zí : Interleave Z with
                                                                                          Zz2 : Z rotated clockwise by 180 degrees (simply reversing would be a bye shorter but would modify the original array)
                                                                                          * : Reduce each pair by multiplcation
                                                                                          ) : End interleave
                                                                                          Å : Slice off the first element
                                                                                          ¤ : Slice off the first 2 elements
                                                                                          x : Reduce by addition
                                                                                          } :End function
                                                                                          g :Pass the following as Z, push the result back to it and repeat until it has length U
                                                                                          4Æ1 :Map the range [0,4) to 1s
                                                                                          :Implicit output of the last element





                                                                                          share|improve this answer












                                                                                          $endgroup$




                                                                                          Japt, 19 17 16 bytes



                                                                                          Outputs the nth term, 1-indexed.



                                                                                          @Zí*Zz2)Ťx}g4Æ1


                                                                                          Try it



                                                                                          @Zí*Zz2)Ťx}g4Æ1 :Implicit input of integer U
                                                                                          @ :Function taking an array as an argument via parameter Z
                                                                                          Zí : Interleave Z with
                                                                                          Zz2 : Z rotated clockwise by 180 degrees (simply reversing would be a bye shorter but would modify the original array)
                                                                                          * : Reduce each pair by multiplcation
                                                                                          ) : End interleave
                                                                                          Å : Slice off the first element
                                                                                          ¤ : Slice off the first 2 elements
                                                                                          x : Reduce by addition
                                                                                          } :End function
                                                                                          g :Pass the following as Z, push the result back to it and repeat until it has length U
                                                                                          4Æ1 :Map the range [0,4) to 1s
                                                                                          :Implicit output of the last element






                                                                                          share|improve this answer















                                                                                          share|improve this answer




                                                                                          share|improve this answer








                                                                                          edited Sep 20 at 9:57

























                                                                                          answered Sep 19 at 17:08









                                                                                          ShaggyShaggy

                                                                                          23.5k3 gold badges21 silver badges73 bronze badges




                                                                                          23.5k3 gold badges21 silver badges73 bronze badges
























                                                                                              1

















                                                                                              $begingroup$


                                                                                              Haskell, 65 bytes





                                                                                              f a|a<4=1|z<-g[2..a]=sum$zipWith(*)z$reverse(1:g[0..a-4])
                                                                                              g=map f


                                                                                              Try it online!



                                                                                              You can use either f to get a single element of a sequence, or pass a list of values to g and get all the indexes for that list.






                                                                                              share|improve this answer












                                                                                              $endgroup$


















                                                                                                1

















                                                                                                $begingroup$


                                                                                                Haskell, 65 bytes





                                                                                                f a|a<4=1|z<-g[2..a]=sum$zipWith(*)z$reverse(1:g[0..a-4])
                                                                                                g=map f


                                                                                                Try it online!



                                                                                                You can use either f to get a single element of a sequence, or pass a list of values to g and get all the indexes for that list.






                                                                                                share|improve this answer












                                                                                                $endgroup$
















                                                                                                  1















                                                                                                  1











                                                                                                  1







                                                                                                  $begingroup$


                                                                                                  Haskell, 65 bytes





                                                                                                  f a|a<4=1|z<-g[2..a]=sum$zipWith(*)z$reverse(1:g[0..a-4])
                                                                                                  g=map f


                                                                                                  Try it online!



                                                                                                  You can use either f to get a single element of a sequence, or pass a list of values to g and get all the indexes for that list.






                                                                                                  share|improve this answer












                                                                                                  $endgroup$




                                                                                                  Haskell, 65 bytes





                                                                                                  f a|a<4=1|z<-g[2..a]=sum$zipWith(*)z$reverse(1:g[0..a-4])
                                                                                                  g=map f


                                                                                                  Try it online!



                                                                                                  You can use either f to get a single element of a sequence, or pass a list of values to g and get all the indexes for that list.







                                                                                                  share|improve this answer















                                                                                                  share|improve this answer




                                                                                                  share|improve this answer








                                                                                                  edited Sep 19 at 13:41

























                                                                                                  answered Sep 19 at 13:36









                                                                                                  Jo KingJo King

                                                                                                  36k4 gold badges78 silver badges151 bronze badges




                                                                                                  36k4 gold badges78 silver badges151 bronze badges
























                                                                                                      1

















                                                                                                      $begingroup$


                                                                                                      Forth (gforth), 99 81 bytes





                                                                                                      : f recursive dup 4 > if 0 over 3 do over 1- i - f i f * + loop else 1 then nip ;


                                                                                                      Try it online!



                                                                                                      Output is nth term and input is 1-indexed



                                                                                                      Edit: Saved 17 bytes by switching to xnor's formula. Saved another 1 byte by using 1-indexed



                                                                                                      Code Explanation



                                                                                                      : f start a new word definition
                                                                                                      recursive mark that this word will be recursive
                                                                                                      dup 4 > duplicate the input and check if it is greater than 4
                                                                                                      if if it is:
                                                                                                      0 over create an accumulator and copy n to top of stack
                                                                                                      3 do start counted loop from 3 to n-1
                                                                                                      over 1- i - f recursively calculate f(n-1-i)
                                                                                                      i f recursively calculate f(i)
                                                                                                      * + multiply results and add to accumulator
                                                                                                      loop end the counted loop
                                                                                                      else otherwise, if n < 5
                                                                                                      1 put 1 on the stack
                                                                                                      then end the if block
                                                                                                      nip drop n from the stack
                                                                                                      ; end the word definition





                                                                                                      share|improve this answer












                                                                                                      $endgroup$


















                                                                                                        1

















                                                                                                        $begingroup$


                                                                                                        Forth (gforth), 99 81 bytes





                                                                                                        : f recursive dup 4 > if 0 over 3 do over 1- i - f i f * + loop else 1 then nip ;


                                                                                                        Try it online!



                                                                                                        Output is nth term and input is 1-indexed



                                                                                                        Edit: Saved 17 bytes by switching to xnor's formula. Saved another 1 byte by using 1-indexed



                                                                                                        Code Explanation



                                                                                                        : f start a new word definition
                                                                                                        recursive mark that this word will be recursive
                                                                                                        dup 4 > duplicate the input and check if it is greater than 4
                                                                                                        if if it is:
                                                                                                        0 over create an accumulator and copy n to top of stack
                                                                                                        3 do start counted loop from 3 to n-1
                                                                                                        over 1- i - f recursively calculate f(n-1-i)
                                                                                                        i f recursively calculate f(i)
                                                                                                        * + multiply results and add to accumulator
                                                                                                        loop end the counted loop
                                                                                                        else otherwise, if n < 5
                                                                                                        1 put 1 on the stack
                                                                                                        then end the if block
                                                                                                        nip drop n from the stack
                                                                                                        ; end the word definition





                                                                                                        share|improve this answer












                                                                                                        $endgroup$
















                                                                                                          1















                                                                                                          1











                                                                                                          1







                                                                                                          $begingroup$


                                                                                                          Forth (gforth), 99 81 bytes





                                                                                                          : f recursive dup 4 > if 0 over 3 do over 1- i - f i f * + loop else 1 then nip ;


                                                                                                          Try it online!



                                                                                                          Output is nth term and input is 1-indexed



                                                                                                          Edit: Saved 17 bytes by switching to xnor's formula. Saved another 1 byte by using 1-indexed



                                                                                                          Code Explanation



                                                                                                          : f start a new word definition
                                                                                                          recursive mark that this word will be recursive
                                                                                                          dup 4 > duplicate the input and check if it is greater than 4
                                                                                                          if if it is:
                                                                                                          0 over create an accumulator and copy n to top of stack
                                                                                                          3 do start counted loop from 3 to n-1
                                                                                                          over 1- i - f recursively calculate f(n-1-i)
                                                                                                          i f recursively calculate f(i)
                                                                                                          * + multiply results and add to accumulator
                                                                                                          loop end the counted loop
                                                                                                          else otherwise, if n < 5
                                                                                                          1 put 1 on the stack
                                                                                                          then end the if block
                                                                                                          nip drop n from the stack
                                                                                                          ; end the word definition





                                                                                                          share|improve this answer












                                                                                                          $endgroup$




                                                                                                          Forth (gforth), 99 81 bytes





                                                                                                          : f recursive dup 4 > if 0 over 3 do over 1- i - f i f * + loop else 1 then nip ;


                                                                                                          Try it online!



                                                                                                          Output is nth term and input is 1-indexed



                                                                                                          Edit: Saved 17 bytes by switching to xnor's formula. Saved another 1 byte by using 1-indexed



                                                                                                          Code Explanation



                                                                                                          : f start a new word definition
                                                                                                          recursive mark that this word will be recursive
                                                                                                          dup 4 > duplicate the input and check if it is greater than 4
                                                                                                          if if it is:
                                                                                                          0 over create an accumulator and copy n to top of stack
                                                                                                          3 do start counted loop from 3 to n-1
                                                                                                          over 1- i - f recursively calculate f(n-1-i)
                                                                                                          i f recursively calculate f(i)
                                                                                                          * + multiply results and add to accumulator
                                                                                                          loop end the counted loop
                                                                                                          else otherwise, if n < 5
                                                                                                          1 put 1 on the stack
                                                                                                          then end the if block
                                                                                                          nip drop n from the stack
                                                                                                          ; end the word definition






                                                                                                          share|improve this answer















                                                                                                          share|improve this answer




                                                                                                          share|improve this answer








                                                                                                          edited Sep 20 at 20:17

























                                                                                                          answered Sep 20 at 14:39









                                                                                                          reffureffu

                                                                                                          1,3313 silver badges7 bronze badges




                                                                                                          1,3313 silver badges7 bronze badges
























                                                                                                              1

















                                                                                                              $begingroup$


                                                                                                              Charcoal, 26 bytes



                                                                                                              F⁵⊞υ¹FN⊞υΣ✂E⮌υ×κ§υλ³→I§υ±⁴


                                                                                                              Try it online! Link is to verbose version of code. Prints the 0-indexed nth number, although it calculates using 1-indexing internally. Explanation:



                                                                                                              F⁵⊞υ¹


                                                                                                              Start with a[0] = a[1] = a[2] = a[3] = a[4] = 1. Yes, this is 1-indexed, but then with an extra zeroth value. That's code golf for you.



                                                                                                              FN


                                                                                                              Calculate an additional n terms. This is overkill, but it makes finding the desired term easier when n<5.



                                                                                                              ⊞υΣ✂E⮌υ×κ§υλ³


                                                                                                              For each term, compute the next term as the sum of the terms so far termwise multiplied by the reverse of the terms so far, excluding three terms.






                                                                                                              This is a no-op used to trick Charcoal into parsing the 2-argument form of Slice, otherwise I would have to use a less golfy way of removing three terms.



                                                                                                              I§υ±⁴


                                                                                                              Output the 4th last term.






                                                                                                              share|improve this answer










                                                                                                              $endgroup$


















                                                                                                                1

















                                                                                                                $begingroup$


                                                                                                                Charcoal, 26 bytes



                                                                                                                F⁵⊞υ¹FN⊞υΣ✂E⮌υ×κ§υλ³→I§υ±⁴


                                                                                                                Try it online! Link is to verbose version of code. Prints the 0-indexed nth number, although it calculates using 1-indexing internally. Explanation:



                                                                                                                F⁵⊞υ¹


                                                                                                                Start with a[0] = a[1] = a[2] = a[3] = a[4] = 1. Yes, this is 1-indexed, but then with an extra zeroth value. That's code golf for you.



                                                                                                                FN


                                                                                                                Calculate an additional n terms. This is overkill, but it makes finding the desired term easier when n<5.



                                                                                                                ⊞υΣ✂E⮌υ×κ§υλ³


                                                                                                                For each term, compute the next term as the sum of the terms so far termwise multiplied by the reverse of the terms so far, excluding three terms.






                                                                                                                This is a no-op used to trick Charcoal into parsing the 2-argument form of Slice, otherwise I would have to use a less golfy way of removing three terms.



                                                                                                                I§υ±⁴


                                                                                                                Output the 4th last term.






                                                                                                                share|improve this answer










                                                                                                                $endgroup$
















                                                                                                                  1















                                                                                                                  1











                                                                                                                  1







                                                                                                                  $begingroup$


                                                                                                                  Charcoal, 26 bytes



                                                                                                                  F⁵⊞υ¹FN⊞υΣ✂E⮌υ×κ§υλ³→I§υ±⁴


                                                                                                                  Try it online! Link is to verbose version of code. Prints the 0-indexed nth number, although it calculates using 1-indexing internally. Explanation:



                                                                                                                  F⁵⊞υ¹


                                                                                                                  Start with a[0] = a[1] = a[2] = a[3] = a[4] = 1. Yes, this is 1-indexed, but then with an extra zeroth value. That's code golf for you.



                                                                                                                  FN


                                                                                                                  Calculate an additional n terms. This is overkill, but it makes finding the desired term easier when n<5.



                                                                                                                  ⊞υΣ✂E⮌υ×κ§υλ³


                                                                                                                  For each term, compute the next term as the sum of the terms so far termwise multiplied by the reverse of the terms so far, excluding three terms.






                                                                                                                  This is a no-op used to trick Charcoal into parsing the 2-argument form of Slice, otherwise I would have to use a less golfy way of removing three terms.



                                                                                                                  I§υ±⁴


                                                                                                                  Output the 4th last term.






                                                                                                                  share|improve this answer










                                                                                                                  $endgroup$




                                                                                                                  Charcoal, 26 bytes



                                                                                                                  F⁵⊞υ¹FN⊞υΣ✂E⮌υ×κ§υλ³→I§υ±⁴


                                                                                                                  Try it online! Link is to verbose version of code. Prints the 0-indexed nth number, although it calculates using 1-indexing internally. Explanation:



                                                                                                                  F⁵⊞υ¹


                                                                                                                  Start with a[0] = a[1] = a[2] = a[3] = a[4] = 1. Yes, this is 1-indexed, but then with an extra zeroth value. That's code golf for you.



                                                                                                                  FN


                                                                                                                  Calculate an additional n terms. This is overkill, but it makes finding the desired term easier when n<5.



                                                                                                                  ⊞υΣ✂E⮌υ×κ§υλ³


                                                                                                                  For each term, compute the next term as the sum of the terms so far termwise multiplied by the reverse of the terms so far, excluding three terms.






                                                                                                                  This is a no-op used to trick Charcoal into parsing the 2-argument form of Slice, otherwise I would have to use a less golfy way of removing three terms.



                                                                                                                  I§υ±⁴


                                                                                                                  Output the 4th last term.







                                                                                                                  share|improve this answer













                                                                                                                  share|improve this answer




                                                                                                                  share|improve this answer










                                                                                                                  answered Sep 21 at 10:19









                                                                                                                  NeilNeil

                                                                                                                  92.1k8 gold badges47 silver badges191 bronze badges




                                                                                                                  92.1k8 gold badges47 silver badges191 bronze badges
























                                                                                                                      1

















                                                                                                                      $begingroup$


                                                                                                                      Pyth, 30 bytes



                                                                                                                      J*4]1VQ=+J+eJsPP*M.t,PJ_PJ0;<J


                                                                                                                      Try it online!



                                                                                                                      Returns the first $n$ elements of the sequence.



                                                                                                                      J*4]1VQ=+J+eJsPP*M.t,PJ_PJ0;<JQ # Full program, last Q = input (implicitly added)
                                                                                                                      J*4]1 # J = 4 * [1] (=[1,1,1,1])
                                                                                                                      VQ # for N in range(Q):
                                                                                                                      =+J # J +=
                                                                                                                      +eJ # J[-1] +
                                                                                                                      s # sum( )
                                                                                                                      *M # map(__operator_mul, )
                                                                                                                      .t 0 # transpose( , pad=0)
                                                                                                                      , # [ , ]
                                                                                                                      PJ # J[:-1]
                                                                                                                      _PJ # J[1::-1]
                                                                                                                      <JQ # J[::Q]


                                                                                                                      Alternative: Replace < with @ to return the $n$-th element of the sequence, 0-indexed.






                                                                                                                      share|improve this answer










                                                                                                                      $endgroup$


















                                                                                                                        1

















                                                                                                                        $begingroup$


                                                                                                                        Pyth, 30 bytes



                                                                                                                        J*4]1VQ=+J+eJsPP*M.t,PJ_PJ0;<J


                                                                                                                        Try it online!



                                                                                                                        Returns the first $n$ elements of the sequence.



                                                                                                                        J*4]1VQ=+J+eJsPP*M.t,PJ_PJ0;<JQ # Full program, last Q = input (implicitly added)
                                                                                                                        J*4]1 # J = 4 * [1] (=[1,1,1,1])
                                                                                                                        VQ # for N in range(Q):
                                                                                                                        =+J # J +=
                                                                                                                        +eJ # J[-1] +
                                                                                                                        s # sum( )
                                                                                                                        *M # map(__operator_mul, )
                                                                                                                        .t 0 # transpose( , pad=0)
                                                                                                                        , # [ , ]
                                                                                                                        PJ # J[:-1]
                                                                                                                        _PJ # J[1::-1]
                                                                                                                        <JQ # J[::Q]


                                                                                                                        Alternative: Replace < with @ to return the $n$-th element of the sequence, 0-indexed.






                                                                                                                        share|improve this answer










                                                                                                                        $endgroup$
















                                                                                                                          1















                                                                                                                          1











                                                                                                                          1







                                                                                                                          $begingroup$


                                                                                                                          Pyth, 30 bytes



                                                                                                                          J*4]1VQ=+J+eJsPP*M.t,PJ_PJ0;<J


                                                                                                                          Try it online!



                                                                                                                          Returns the first $n$ elements of the sequence.



                                                                                                                          J*4]1VQ=+J+eJsPP*M.t,PJ_PJ0;<JQ # Full program, last Q = input (implicitly added)
                                                                                                                          J*4]1 # J = 4 * [1] (=[1,1,1,1])
                                                                                                                          VQ # for N in range(Q):
                                                                                                                          =+J # J +=
                                                                                                                          +eJ # J[-1] +
                                                                                                                          s # sum( )
                                                                                                                          *M # map(__operator_mul, )
                                                                                                                          .t 0 # transpose( , pad=0)
                                                                                                                          , # [ , ]
                                                                                                                          PJ # J[:-1]
                                                                                                                          _PJ # J[1::-1]
                                                                                                                          <JQ # J[::Q]


                                                                                                                          Alternative: Replace < with @ to return the $n$-th element of the sequence, 0-indexed.






                                                                                                                          share|improve this answer










                                                                                                                          $endgroup$




                                                                                                                          Pyth, 30 bytes



                                                                                                                          J*4]1VQ=+J+eJsPP*M.t,PJ_PJ0;<J


                                                                                                                          Try it online!



                                                                                                                          Returns the first $n$ elements of the sequence.



                                                                                                                          J*4]1VQ=+J+eJsPP*M.t,PJ_PJ0;<JQ # Full program, last Q = input (implicitly added)
                                                                                                                          J*4]1 # J = 4 * [1] (=[1,1,1,1])
                                                                                                                          VQ # for N in range(Q):
                                                                                                                          =+J # J +=
                                                                                                                          +eJ # J[-1] +
                                                                                                                          s # sum( )
                                                                                                                          *M # map(__operator_mul, )
                                                                                                                          .t 0 # transpose( , pad=0)
                                                                                                                          , # [ , ]
                                                                                                                          PJ # J[:-1]
                                                                                                                          _PJ # J[1::-1]
                                                                                                                          <JQ # J[::Q]


                                                                                                                          Alternative: Replace < with @ to return the $n$-th element of the sequence, 0-indexed.







                                                                                                                          share|improve this answer













                                                                                                                          share|improve this answer




                                                                                                                          share|improve this answer










                                                                                                                          answered Sep 21 at 11:16









                                                                                                                          ar4093ar4093

                                                                                                                          5017 bronze badges




                                                                                                                          5017 bronze badges
























                                                                                                                              1

















                                                                                                                              $begingroup$


                                                                                                                              Ruby, 42 41 bytes





                                                                                                                              f=->nn<4?1:(4..n).sum


                                                                                                                              Try it online!



                                                                                                                              1-indexed (to save 1 byte)






                                                                                                                              share|improve this answer












                                                                                                                              $endgroup$


















                                                                                                                                1

















                                                                                                                                $begingroup$


                                                                                                                                Ruby, 42 41 bytes





                                                                                                                                f=->nn<4?1:(4..n).sum


                                                                                                                                Try it online!



                                                                                                                                1-indexed (to save 1 byte)






                                                                                                                                share|improve this answer












                                                                                                                                $endgroup$
















                                                                                                                                  1















                                                                                                                                  1











                                                                                                                                  1







                                                                                                                                  $begingroup$


                                                                                                                                  Ruby, 42 41 bytes





                                                                                                                                  f=->nn<4?1:(4..n).sum


                                                                                                                                  Try it online!



                                                                                                                                  1-indexed (to save 1 byte)






                                                                                                                                  share|improve this answer












                                                                                                                                  $endgroup$




                                                                                                                                  Ruby, 42 41 bytes





                                                                                                                                  f=->nn<4?1:(4..n).sum


                                                                                                                                  Try it online!



                                                                                                                                  1-indexed (to save 1 byte)







                                                                                                                                  share|improve this answer















                                                                                                                                  share|improve this answer




                                                                                                                                  share|improve this answer








                                                                                                                                  edited Sep 21 at 12:50

























                                                                                                                                  answered Sep 20 at 6:24









                                                                                                                                  G BG B

                                                                                                                                  9,74914 silver badges32 bronze badges




                                                                                                                                  9,74914 silver badges32 bronze badges
























                                                                                                                                      1

















                                                                                                                                      $begingroup$


                                                                                                                                      Octave, 73 bytes





                                                                                                                                      g=(1:4).^0;for(i=3:(n=input('')))g(i+2)=g(4:i+1)*g(i-(2:i-1))';end;g(end)


                                                                                                                                      Try it online!



                                                                                                                                      -2 bytes thanks to Stewie Griffin. Once more, the imperative approach wins over the functional recursive approach. That one is shown below.




                                                                                                                                      Octave, 75 bytes





                                                                                                                                      f(f=@(a)@(n)@()sum(arrayfun(@(k)a(a)(k)*a(a)(n-2-k),2:n-1)),12-(n>3)())


                                                                                                                                      Try it online!



                                                                                                                                      Captcha wanted to verify I was a human when posting this. To be honest, I'm not so sure.






                                                                                                                                      share|improve this answer












                                                                                                                                      $endgroup$













                                                                                                                                      • $begingroup$
                                                                                                                                        I can't see any obvious ways to shorten the loop approach... It looks pretty well golfed! Also, it's not often I see zero-based indexing in Octave :)
                                                                                                                                        $endgroup$
                                                                                                                                        – Stewie Griffin
                                                                                                                                        Sep 20 at 12:50











                                                                                                                                      • $begingroup$
                                                                                                                                        @StewieGriffin Since the recursion has some offsets it doesn't really matter if you pick zero- or one indexing. I think maybe I could shave some bytes of if I did 2-indexing, but that seemed like cheating. Anyway, your intuition was right - somehow, this was indeed shorter in an anonymous recursive way. I think the main advantage is that it handles creating the four initial values very well because it just returns 1 for n<4.
                                                                                                                                        $endgroup$
                                                                                                                                        – Sanchises
                                                                                                                                        Sep 20 at 13:00






                                                                                                                                      • 1




                                                                                                                                        $begingroup$
                                                                                                                                        @StewieGriffin Of course, good old matrix multiplication. Well done!
                                                                                                                                        $endgroup$
                                                                                                                                        – Sanchises
                                                                                                                                        Sep 22 at 15:49















                                                                                                                                      1

















                                                                                                                                      $begingroup$


                                                                                                                                      Octave, 73 bytes





                                                                                                                                      g=(1:4).^0;for(i=3:(n=input('')))g(i+2)=g(4:i+1)*g(i-(2:i-1))';end;g(end)


                                                                                                                                      Try it online!



                                                                                                                                      -2 bytes thanks to Stewie Griffin. Once more, the imperative approach wins over the functional recursive approach. That one is shown below.




                                                                                                                                      Octave, 75 bytes





                                                                                                                                      f(f=@(a)@(n)@()sum(arrayfun(@(k)a(a)(k)*a(a)(n-2-k),2:n-1)),12-(n>3)())


                                                                                                                                      Try it online!



                                                                                                                                      Captcha wanted to verify I was a human when posting this. To be honest, I'm not so sure.






                                                                                                                                      share|improve this answer












                                                                                                                                      $endgroup$













                                                                                                                                      • $begingroup$
                                                                                                                                        I can't see any obvious ways to shorten the loop approach... It looks pretty well golfed! Also, it's not often I see zero-based indexing in Octave :)
                                                                                                                                        $endgroup$
                                                                                                                                        – Stewie Griffin
                                                                                                                                        Sep 20 at 12:50











                                                                                                                                      • $begingroup$
                                                                                                                                        @StewieGriffin Since the recursion has some offsets it doesn't really matter if you pick zero- or one indexing. I think maybe I could shave some bytes of if I did 2-indexing, but that seemed like cheating. Anyway, your intuition was right - somehow, this was indeed shorter in an anonymous recursive way. I think the main advantage is that it handles creating the four initial values very well because it just returns 1 for n<4.
                                                                                                                                        $endgroup$
                                                                                                                                        – Sanchises
                                                                                                                                        Sep 20 at 13:00






                                                                                                                                      • 1




                                                                                                                                        $begingroup$
                                                                                                                                        @StewieGriffin Of course, good old matrix multiplication. Well done!
                                                                                                                                        $endgroup$
                                                                                                                                        – Sanchises
                                                                                                                                        Sep 22 at 15:49













                                                                                                                                      1















                                                                                                                                      1











                                                                                                                                      1







                                                                                                                                      $begingroup$


                                                                                                                                      Octave, 73 bytes





                                                                                                                                      g=(1:4).^0;for(i=3:(n=input('')))g(i+2)=g(4:i+1)*g(i-(2:i-1))';end;g(end)


                                                                                                                                      Try it online!



                                                                                                                                      -2 bytes thanks to Stewie Griffin. Once more, the imperative approach wins over the functional recursive approach. That one is shown below.




                                                                                                                                      Octave, 75 bytes





                                                                                                                                      f(f=@(a)@(n)@()sum(arrayfun(@(k)a(a)(k)*a(a)(n-2-k),2:n-1)),12-(n>3)())


                                                                                                                                      Try it online!



                                                                                                                                      Captcha wanted to verify I was a human when posting this. To be honest, I'm not so sure.






                                                                                                                                      share|improve this answer












                                                                                                                                      $endgroup$




                                                                                                                                      Octave, 73 bytes





                                                                                                                                      g=(1:4).^0;for(i=3:(n=input('')))g(i+2)=g(4:i+1)*g(i-(2:i-1))';end;g(end)


                                                                                                                                      Try it online!



                                                                                                                                      -2 bytes thanks to Stewie Griffin. Once more, the imperative approach wins over the functional recursive approach. That one is shown below.




                                                                                                                                      Octave, 75 bytes





                                                                                                                                      f(f=@(a)@(n)@()sum(arrayfun(@(k)a(a)(k)*a(a)(n-2-k),2:n-1)),12-(n>3)())


                                                                                                                                      Try it online!



                                                                                                                                      Captcha wanted to verify I was a human when posting this. To be honest, I'm not so sure.







                                                                                                                                      share|improve this answer















                                                                                                                                      share|improve this answer




                                                                                                                                      share|improve this answer








                                                                                                                                      edited Sep 24 at 6:57

























                                                                                                                                      answered Sep 20 at 12:19









                                                                                                                                      SanchisesSanchises

                                                                                                                                      8,4411 gold badge25 silver badges56 bronze badges




                                                                                                                                      8,4411 gold badge25 silver badges56 bronze badges














                                                                                                                                      • $begingroup$
                                                                                                                                        I can't see any obvious ways to shorten the loop approach... It looks pretty well golfed! Also, it's not often I see zero-based indexing in Octave :)
                                                                                                                                        $endgroup$
                                                                                                                                        – Stewie Griffin
                                                                                                                                        Sep 20 at 12:50











                                                                                                                                      • $begingroup$
                                                                                                                                        @StewieGriffin Since the recursion has some offsets it doesn't really matter if you pick zero- or one indexing. I think maybe I could shave some bytes of if I did 2-indexing, but that seemed like cheating. Anyway, your intuition was right - somehow, this was indeed shorter in an anonymous recursive way. I think the main advantage is that it handles creating the four initial values very well because it just returns 1 for n<4.
                                                                                                                                        $endgroup$
                                                                                                                                        – Sanchises
                                                                                                                                        Sep 20 at 13:00






                                                                                                                                      • 1




                                                                                                                                        $begingroup$
                                                                                                                                        @StewieGriffin Of course, good old matrix multiplication. Well done!
                                                                                                                                        $endgroup$
                                                                                                                                        – Sanchises
                                                                                                                                        Sep 22 at 15:49
















                                                                                                                                      • $begingroup$
                                                                                                                                        I can't see any obvious ways to shorten the loop approach... It looks pretty well golfed! Also, it's not often I see zero-based indexing in Octave :)
                                                                                                                                        $endgroup$
                                                                                                                                        – Stewie Griffin
                                                                                                                                        Sep 20 at 12:50











                                                                                                                                      • $begingroup$
                                                                                                                                        @StewieGriffin Since the recursion has some offsets it doesn't really matter if you pick zero- or one indexing. I think maybe I could shave some bytes of if I did 2-indexing, but that seemed like cheating. Anyway, your intuition was right - somehow, this was indeed shorter in an anonymous recursive way. I think the main advantage is that it handles creating the four initial values very well because it just returns 1 for n<4.
                                                                                                                                        $endgroup$
                                                                                                                                        – Sanchises
                                                                                                                                        Sep 20 at 13:00






                                                                                                                                      • 1




                                                                                                                                        $begingroup$
                                                                                                                                        @StewieGriffin Of course, good old matrix multiplication. Well done!
                                                                                                                                        $endgroup$
                                                                                                                                        – Sanchises
                                                                                                                                        Sep 22 at 15:49















                                                                                                                                      $begingroup$
                                                                                                                                      I can't see any obvious ways to shorten the loop approach... It looks pretty well golfed! Also, it's not often I see zero-based indexing in Octave :)
                                                                                                                                      $endgroup$
                                                                                                                                      – Stewie Griffin
                                                                                                                                      Sep 20 at 12:50





                                                                                                                                      $begingroup$
                                                                                                                                      I can't see any obvious ways to shorten the loop approach... It looks pretty well golfed! Also, it's not often I see zero-based indexing in Octave :)
                                                                                                                                      $endgroup$
                                                                                                                                      – Stewie Griffin
                                                                                                                                      Sep 20 at 12:50













                                                                                                                                      $begingroup$
                                                                                                                                      @StewieGriffin Since the recursion has some offsets it doesn't really matter if you pick zero- or one indexing. I think maybe I could shave some bytes of if I did 2-indexing, but that seemed like cheating. Anyway, your intuition was right - somehow, this was indeed shorter in an anonymous recursive way. I think the main advantage is that it handles creating the four initial values very well because it just returns 1 for n<4.
                                                                                                                                      $endgroup$
                                                                                                                                      – Sanchises
                                                                                                                                      Sep 20 at 13:00




                                                                                                                                      $begingroup$
                                                                                                                                      @StewieGriffin Since the recursion has some offsets it doesn't really matter if you pick zero- or one indexing. I think maybe I could shave some bytes of if I did 2-indexing, but that seemed like cheating. Anyway, your intuition was right - somehow, this was indeed shorter in an anonymous recursive way. I think the main advantage is that it handles creating the four initial values very well because it just returns 1 for n<4.
                                                                                                                                      $endgroup$
                                                                                                                                      – Sanchises
                                                                                                                                      Sep 20 at 13:00




                                                                                                                                      1




                                                                                                                                      1




                                                                                                                                      $begingroup$
                                                                                                                                      @StewieGriffin Of course, good old matrix multiplication. Well done!
                                                                                                                                      $endgroup$
                                                                                                                                      – Sanchises
                                                                                                                                      Sep 22 at 15:49




                                                                                                                                      $begingroup$
                                                                                                                                      @StewieGriffin Of course, good old matrix multiplication. Well done!
                                                                                                                                      $endgroup$
                                                                                                                                      – Sanchises
                                                                                                                                      Sep 22 at 15:49











                                                                                                                                      0

















                                                                                                                                      $begingroup$


                                                                                                                                      Perl 5 -MList::Util=sum, 61 bytes





                                                                                                                                      sub asum a($b+1),mapa($_)*a($b-$_)2..$b


                                                                                                                                      Try it online!






                                                                                                                                      share|improve this answer










                                                                                                                                      $endgroup$


















                                                                                                                                        0

















                                                                                                                                        $begingroup$


                                                                                                                                        Perl 5 -MList::Util=sum, 61 bytes





                                                                                                                                        sub asum a($b+1),mapa($_)*a($b-$_)2..$b


                                                                                                                                        Try it online!






                                                                                                                                        share|improve this answer










                                                                                                                                        $endgroup$
















                                                                                                                                          0















                                                                                                                                          0











                                                                                                                                          0







                                                                                                                                          $begingroup$


                                                                                                                                          Perl 5 -MList::Util=sum, 61 bytes





                                                                                                                                          sub asum a($b+1),mapa($_)*a($b-$_)2..$b


                                                                                                                                          Try it online!






                                                                                                                                          share|improve this answer










                                                                                                                                          $endgroup$




                                                                                                                                          Perl 5 -MList::Util=sum, 61 bytes





                                                                                                                                          sub asum a($b+1),mapa($_)*a($b-$_)2..$b


                                                                                                                                          Try it online!







                                                                                                                                          share|improve this answer













                                                                                                                                          share|improve this answer




                                                                                                                                          share|improve this answer










                                                                                                                                          answered Sep 19 at 17:55









                                                                                                                                          XcaliXcali

                                                                                                                                          7,2741 gold badge7 silver badges25 bronze badges




                                                                                                                                          7,2741 gold badge7 silver badges25 bronze badges
























                                                                                                                                              0

















                                                                                                                                              $begingroup$


                                                                                                                                              C/C++, 70 69 67 bytes



                                                                                                                                              -1 bytes thanks to Jonathan.



                                                                                                                                              int a(int n)int k=2,s=0;while(++k<n)s+=a(k)*a(n+~k);return s?s:1;


                                                                                                                                              Try it online!






                                                                                                                                              share|improve this answer












                                                                                                                                              $endgroup$













                                                                                                                                              • $begingroup$
                                                                                                                                                Can a(n-1-k) be a(n+~k)?
                                                                                                                                                $endgroup$
                                                                                                                                                – Jonathan Frech
                                                                                                                                                Sep 21 at 12:00










                                                                                                                                              • $begingroup$
                                                                                                                                                @JonathanFrech even a(++k)*a(n-k) is likely to work, and it drops further 2 bytes from for. But I smell undefined behavior.
                                                                                                                                                $endgroup$
                                                                                                                                                – polfosol ఠ_ఠ
                                                                                                                                                Sep 21 at 12:25










                                                                                                                                              • $begingroup$
                                                                                                                                                That appears to be a sequencing issue; most definitely UB.
                                                                                                                                                $endgroup$
                                                                                                                                                – Jonathan Frech
                                                                                                                                                Sep 21 at 18:16















                                                                                                                                              0

















                                                                                                                                              $begingroup$


                                                                                                                                              C/C++, 70 69 67 bytes



                                                                                                                                              -1 bytes thanks to Jonathan.



                                                                                                                                              int a(int n)int k=2,s=0;while(++k<n)s+=a(k)*a(n+~k);return s?s:1;


                                                                                                                                              Try it online!






                                                                                                                                              share|improve this answer












                                                                                                                                              $endgroup$













                                                                                                                                              • $begingroup$
                                                                                                                                                Can a(n-1-k) be a(n+~k)?
                                                                                                                                                $endgroup$
                                                                                                                                                – Jonathan Frech
                                                                                                                                                Sep 21 at 12:00










                                                                                                                                              • $begingroup$
                                                                                                                                                @JonathanFrech even a(++k)*a(n-k) is likely to work, and it drops further 2 bytes from for. But I smell undefined behavior.
                                                                                                                                                $endgroup$
                                                                                                                                                – polfosol ఠ_ఠ
                                                                                                                                                Sep 21 at 12:25










                                                                                                                                              • $begingroup$
                                                                                                                                                That appears to be a sequencing issue; most definitely UB.
                                                                                                                                                $endgroup$
                                                                                                                                                – Jonathan Frech
                                                                                                                                                Sep 21 at 18:16













                                                                                                                                              0















                                                                                                                                              0











                                                                                                                                              0







                                                                                                                                              $begingroup$


                                                                                                                                              C/C++, 70 69 67 bytes



                                                                                                                                              -1 bytes thanks to Jonathan.



                                                                                                                                              int a(int n)int k=2,s=0;while(++k<n)s+=a(k)*a(n+~k);return s?s:1;


                                                                                                                                              Try it online!






                                                                                                                                              share|improve this answer












                                                                                                                                              $endgroup$




                                                                                                                                              C/C++, 70 69 67 bytes



                                                                                                                                              -1 bytes thanks to Jonathan.



                                                                                                                                              int a(int n)int k=2,s=0;while(++k<n)s+=a(k)*a(n+~k);return s?s:1;


                                                                                                                                              Try it online!







                                                                                                                                              share|improve this answer















                                                                                                                                              share|improve this answer




                                                                                                                                              share|improve this answer








                                                                                                                                              edited Sep 21 at 13:26

























                                                                                                                                              answered Sep 21 at 10:51









                                                                                                                                              polfosol ఠ_ఠpolfosol ఠ_ఠ

                                                                                                                                              5093 silver badges9 bronze badges




                                                                                                                                              5093 silver badges9 bronze badges














                                                                                                                                              • $begingroup$
                                                                                                                                                Can a(n-1-k) be a(n+~k)?
                                                                                                                                                $endgroup$
                                                                                                                                                – Jonathan Frech
                                                                                                                                                Sep 21 at 12:00










                                                                                                                                              • $begingroup$
                                                                                                                                                @JonathanFrech even a(++k)*a(n-k) is likely to work, and it drops further 2 bytes from for. But I smell undefined behavior.
                                                                                                                                                $endgroup$
                                                                                                                                                – polfosol ఠ_ఠ
                                                                                                                                                Sep 21 at 12:25










                                                                                                                                              • $begingroup$
                                                                                                                                                That appears to be a sequencing issue; most definitely UB.
                                                                                                                                                $endgroup$
                                                                                                                                                – Jonathan Frech
                                                                                                                                                Sep 21 at 18:16
















                                                                                                                                              • $begingroup$
                                                                                                                                                Can a(n-1-k) be a(n+~k)?
                                                                                                                                                $endgroup$
                                                                                                                                                – Jonathan Frech
                                                                                                                                                Sep 21 at 12:00










                                                                                                                                              • $begingroup$
                                                                                                                                                @JonathanFrech even a(++k)*a(n-k) is likely to work, and it drops further 2 bytes from for. But I smell undefined behavior.
                                                                                                                                                $endgroup$
                                                                                                                                                – polfosol ఠ_ఠ
                                                                                                                                                Sep 21 at 12:25










                                                                                                                                              • $begingroup$
                                                                                                                                                That appears to be a sequencing issue; most definitely UB.
                                                                                                                                                $endgroup$
                                                                                                                                                – Jonathan Frech
                                                                                                                                                Sep 21 at 18:16















                                                                                                                                              $begingroup$
                                                                                                                                              Can a(n-1-k) be a(n+~k)?
                                                                                                                                              $endgroup$
                                                                                                                                              – Jonathan Frech
                                                                                                                                              Sep 21 at 12:00




                                                                                                                                              $begingroup$
                                                                                                                                              Can a(n-1-k) be a(n+~k)?
                                                                                                                                              $endgroup$
                                                                                                                                              – Jonathan Frech
                                                                                                                                              Sep 21 at 12:00












                                                                                                                                              $begingroup$
                                                                                                                                              @JonathanFrech even a(++k)*a(n-k) is likely to work, and it drops further 2 bytes from for. But I smell undefined behavior.
                                                                                                                                              $endgroup$
                                                                                                                                              – polfosol ఠ_ఠ
                                                                                                                                              Sep 21 at 12:25




                                                                                                                                              $begingroup$
                                                                                                                                              @JonathanFrech even a(++k)*a(n-k) is likely to work, and it drops further 2 bytes from for. But I smell undefined behavior.
                                                                                                                                              $endgroup$
                                                                                                                                              – polfosol ఠ_ఠ
                                                                                                                                              Sep 21 at 12:25












                                                                                                                                              $begingroup$
                                                                                                                                              That appears to be a sequencing issue; most definitely UB.
                                                                                                                                              $endgroup$
                                                                                                                                              – Jonathan Frech
                                                                                                                                              Sep 21 at 18:16




                                                                                                                                              $begingroup$
                                                                                                                                              That appears to be a sequencing issue; most definitely UB.
                                                                                                                                              $endgroup$
                                                                                                                                              – Jonathan Frech
                                                                                                                                              Sep 21 at 18:16


















                                                                                                                                              draft saved

                                                                                                                                              draft discarded















































                                                                                                                                              If this is an answer to a challenge…



                                                                                                                                              • …Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.


                                                                                                                                              • …Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
                                                                                                                                                Explanations of your answer make it more interesting to read and are very much encouraged.


                                                                                                                                              • …Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.


                                                                                                                                              More generally…



                                                                                                                                              • …Please make sure to answer the question and provide sufficient detail.


                                                                                                                                              • …Avoid asking for help, clarification or responding to other answers (use comments instead).




                                                                                                                                              draft saved


                                                                                                                                              draft discarded














                                                                                                                                              StackExchange.ready(
                                                                                                                                              function ()
                                                                                                                                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f193170%2f1-2-4-8-16-33%23new-answer', 'question_page');

                                                                                                                                              );

                                                                                                                                              Post as a guest















                                                                                                                                              Required, but never shown





















































                                                                                                                                              Required, but never shown














                                                                                                                                              Required, but never shown












                                                                                                                                              Required, but never shown







                                                                                                                                              Required, but never shown

































                                                                                                                                              Required, but never shown














                                                                                                                                              Required, but never shown












                                                                                                                                              Required, but never shown







                                                                                                                                              Required, but never shown









                                                                                                                                              Popular posts from this blog

                                                                                                                                              Tamil (spriik) Luke uk diar | Nawigatjuun

                                                                                                                                              Align equal signs while including text over equalitiesAMS align: left aligned text/math plus multicolumn alignmentMultiple alignmentsAligning equations in multiple placesNumbering and aligning an equation with multiple columnsHow to align one equation with another multline equationUsing \ in environments inside the begintabularxNumber equations and preserving alignment of equal signsHow can I align equations to the left and to the right?Double equation alignment problem within align enviromentAligned within align: Why are they right-aligned?

                                                                                                                                              Training a classifier when some of the features are unknownWhy does Gradient Boosting regression predict negative values when there are no negative y-values in my training set?How to improve an existing (trained) classifier?What is effect when I set up some self defined predisctor variables?Why Matlab neural network classification returns decimal values on prediction dataset?Fitting and transforming text data in training, testing, and validation setsHow to quantify the performance of the classifier (multi-class SVM) using the test data?How do I control for some patients providing multiple samples in my training data?Training and Test setTraining a convolutional neural network for image denoising in MatlabShouldn't an autoencoder with #(neurons in hidden layer) = #(neurons in input layer) be “perfect”?