Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Ask questions, find answers and collaborate at work with Stack Overflow for Teams.
Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
a n|n<4=1|0<1=sum[an=max(sum[a k*a(n-2-k)|k<-[2..n-1]])1
Try it online!Try it online!
For n<3 the sum is 0, so max ... 1 raises it to 1.
n<3
sum
max ... 1
1
Edit: -6 bytes thanks to @Jo King.
a n|n<4=1|0<1=sum[a k*a(n-2-k)|k<-[2..n-1]]
Try it online!
a n=max(sum[a k*a(n-2-k)|k<-[2..n-1]])1
a n|n<4=1|m<-n-2=a(n-1)+sum[an|n<4=1|0<1=sum[a k*a(mn-2-k)|k<-[2..m]]n-1]]
A direct implementation of the recursive formulaEdit: -6 bytes thanks to @Jo King.
a n|n<4=1|m<-n-2=a(n-1)+sum[a k*a(m-k)|k<-[2..m]]
A direct implementation of the recursive formula.