# One OEIS after another

As of 13/03/2018 16:45 UTC, the winner is answer #345, by Scrooble. This means the contest is officially over, but feel free to continue posting answers, just so long as they follow the rules.

As well, just a quick shout out to the top three answerers in terms of numbers of answers:

3. Hyper Neutrino - 26 answers

This is an answer chaining question that uses sequences from OEIS, and the length of the previous submission.

This answer chaining question will work in the following way:

• I will post the first answer. All other solutions must stem from that.
• The next user (let's call them userA) will find the OEIS sequence in which its index number (see below) is the same as the length of my code.
• Using the sequence, they must then code, in an unused language, a program that takes an integer as input, n, and outputs the nth number in that sequence.
• Next, they post their solution after mine, and a new user (userB) must repeat the same thing.

The nth term of a sequence is the term n times after the first, working with the first value being the first value given on its OEIS page. In this question, we will use 0-indexing for these sequences. For example, with A000242 and n = 3, the correct result would be 25.

## However!

This is not a , so shortest code doesn't matter. But the length of your code does still have an impact. To prevent the duplication of sequences, your bytecount must be unique. This means that no other program submitted here can be the same length in bytes as yours.

If there isn't a sequence for then length of the last post, then the sequence for your post is the lowest unused sequence. This means that the sequences used also have to be unique, and that the sequence cannot be the same as your bytecount.

After an answer has been posted and no new answers have been posted for more than a week, the answer before the last posted (the one who didn't break the chain) will win.

## Input and Output

Generic input and output rules apply. Input must be an integer or a string representation of an integer and output must be the correct value in the sequence.

## Formatting

# N. language, length, [sequence](link)

code

*anything else*


## Rules

• You must wait for at least 1 hour before posting an answer, after having posted.
• You may not post twice (or more) in a row.
• The index number of a sequence is the number after the A part, and with leading zeros removed (e.g. for A000040 the index number is 40)
• You can assume that neither the input nor the required output will be outside your languages numerical range, but please don't abuse this by choosing a language that can only use the number 1, for example.
• If the length of your submission is greater than 65536 characters long, please provide a link to a way to access the code (pastebin for example).
• n will never be larger than 1000, or be out of bounds for the sequence, simply to prevent accuracy discrepancies from stopping a language from competing.
• Every 150 (valid) answers, the number of times a language may be used increases. So after 150 solutions have been posted, every language may be used twice (with all previous answers counting towards this). For instance, when 150 answers have been posted, Python 3 may be used twice, but due to the fact that it has already been used once, this means it can only be used once more until 300 answers have been posted.
• Please be helpful and post a link to the next sequence to be used. This isn't required, but is a recommendation.
• Different versions of languages, e.g. Python 2 and Python 3 are different languages. As a general rule, if the different versions are both available on Try It Online, they are different languages, but keep in mind that this is a general rule and not a rigid answer.
• It is not banned, but please try not to copy the code from the OEIS page, and actually try to solve it.
• Hardcoding is only allowed if the sequence is finite. Please note that the answer that prompted this (#40) is the exception to the rule. A few answers early in the chain hardcode, but these can be ignored, as there is no good in deleting the chain up to, say, #100.

var QUESTION_ID=133754,OVERRIDE_USER=66833;function shareUrl(i){return"https://codegolf.stackexchange.com/a/"+i}function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getTemplate(s){return jQuery(jQuery("#answer-template").html().replace("{{PLACE}}",s.index+".").replace("{{NAME}}",s.user).replace("{{LANGUAGE}}",s.language).replace("{{SEQUENCE}}",s.sequence).replace("{{SIZE}}",s.size).replace("{{LINK}}",s.link))}function search(l,q){m=jQuery("<tbody id='answers'></tbody>");e.forEach(function(s){if(!q||(l==0&&RegExp('^'+q,'i').exec(s.lang_name))||(l==1&&q===''+s.size)){m.append(jQuery(getTemplate(s)))}});jQuery("#answers").remove();jQuery(".answer-list").append(m)}function sortby(ix){t=document.querySelector('#answers');_els=t.querySelectorAll('tr');els=[];for(var i=0;i<_els.length;i++){els.push(_els[i]);}els.sortBy(function(a){a=a.cells[ix].innerText;return ix==0||ix==4?Number(a):a.toLowerCase()});for(var i=0;i<els.length;i++)t.appendChild(els[i]);}function checkSize(x){if(!x)return jQuery("#size-used").text("");var i=b.indexOf(+x);if(i<0)return jQuery("#size-used").text("Available!");var low=+x,high=+x;while(~b.indexOf(low))low--;while(~b.indexOf(high))high++;jQuery("#size-used").text(("Not available. The nearest are "+low+" and "+high).replace("are 0 and","is"))}function checkLang(x){}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.answer_id;answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return (e.owner.user_id==OVERRIDE_USER?"<span id='question-author'>"+e.owner.display_name+"</span>":e.owner.display_name)}function process(){b=[];c=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);if(a){e.push({user:getAuthorName(s),size:+a[4],language:a[2],lang_name:a[3],index:+a[1],sequence:a[5],link:shareUrl(s.answer_id)});if(b.indexOf(+a[4])>=0&&c.indexOf(+a[4])<0){c.push(+a[4])};b.push(+a[4])}else{jQuery('#weird-answers').append('<a href="'+shareUrl(s.answer_id)+'">This answer</a> is not formatted correctly. <b>Do not trust the information provided by this snippet until this message disappears.</b><br />')}}),e.sortBy(function(e){return e.index});e.forEach(function(e){jQuery("#answers").append(getTemplate(e))});var q="A"+("000000"+e.slice(-1)[0].size).slice(-6);jQuery("#next").html("<a href='http://oeis.org/"+q+"'>"+q+"</a>");c.forEach(function(n){jQuery('#weird-answers').append('The bytecount '+n+' was used more than once!<br />')})}Array.prototype.sortBy=function(f){return this.sort(function(a,b){if(f)a=f(a),b=f(b);return(a>b)-(a<b)})};var ANSWER_FILTER="!*RB.h_b*K(IAWbmRBLe",COMMENT_FILTER="!owfmI7e3fd9oB",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page,e=[];getAnswers();var SCORE_REG=/<h\d>\s*(\d+)\.\s*((?:<a [^>]+>\s*)?((?:[^\n,](?!<\/a>))*[^\s,])(?:<\/a>)?),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*, ((?:<a[^>]+>\s*)?A\d+(?:\s*<\/a>)?)\s*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
body{text-align:left!important;font-family:Roboto,sans-serif}#answer-list,#language-list{padding:10px;/*width:290px*/;float:left;display:flex;flex-wrap:wrap;list-style:none;}table thead{font-weight:700}table td{padding:5px}ul{margin:0px}#board{display:flex;flex-direction:column;}#language-list li{padding:2px 5px;}#langs-tit{margin-bottom:5px}#byte-counts{display:block;margin-left:15px;}#question-author{color:purple;text-shadow: 0 0 15px rgba(128,0,128,0.1);}#label-info{font-weight: normal;font-size: 14px;font-style: italic;color: dimgray;padding-left: 10px;vertical-align: middle; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"><p id="weird-answers"></p><p>Currently waiting on <span id="next"></span></p><span>Search by Byte Count: <input id="search" type="number" min=1 oninput="checkSize(this.value);search(1,this.value)" onclick="document.getElementById('search2').value='';!this.value&&search(0,'')"/> <span id="size-used"></span></span><br><span>Search by Language: <input id="search2" oninput="checkLang(this.value);search(0,this.value)" onclick="document.getElementById('search').value='';!this.value&&search(0,'')"/> <span id="language-used"></span></span><h2>Answer chain <span id="label-info">click a label to sort by column</span></h2><table class="answer-list"><thead><tr><td  onclick="sortby(0)">#</td><td onclick="sortby(1)">Author</td><td onclick="sortby(2)">Language</td><td onclick="sortby(3)">Sequence</td><td onclick="sortby(4)">Size</td></tr></thead><tbody id="answers"></tbody></table><table style="display: none"><tbody id="answer-template"><tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SEQUENCE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody></table><table style="display: none"><tbody id="language-template"><tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SEQUENCE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody></table>

• Comments are not for extended discussion; this conversation has been moved to chat. – Dennis Oct 31 '17 at 2:49
• Is it OK if a program would need a better floating-point accuracy for the builtin float/double type in order to produce values for larger n? – NieDzejkob Nov 21 '17 at 15:15
• @Giuseppe No, as you're generating the numbers by doing the maths, rather than just placing them into an array/string – caird coinheringaahing Dec 15 '17 at 22:14
• @cairdcoinheringaahing In my opinion that's hardcoding the gamma constant. It doesn't work "in theory" for larger numbers. – user202729 Dec 22 '17 at 12:44
• Chat room – user202729 Dec 22 '17 at 12:45

# 345. brainfuck, 162 bytes, A000301

+<<,[>>[>]<<[>>+>+<<<-]>>>[<<<+>>>-]<<[>+>+<<-]>>[<<+>>-]<[<]<-]>>[>]+<[-]++<[>[>>+>+<<<-]>>>[<<<+>>>-]<<[>[>+>+<<-]>>[<<+>>-]<<<-]>[-]>[<<+>>-]<<<<-]>>too golfy.


Try it online!

Next sequence!

This takes as input the character with code point n (by BF's specs) and outputs in the same way. To see the numbers, I suggest using @Timwi's EsotericIDE.

### Explanation:

+<<,                                  Initialize the tape with the first two Fibonacci numbers. Take loop counter from input.
[                                     n times:
>>[>]                                 Move to the end of the tape.
<<[>+>+<<-]>>[<<+>>-]                 and fib(n-1). Store on the end of the tape.
<[<]<-                                Move back to start of tape. Update loop counter.
]                                     End loop.
>>[>]+<[-]++<                         Delete the extra Fibonacci number and prepare for exponentiation.
[                                     fib(n) times:
>[>>+>+<<<-]>>>[<<<+>>>-]<<           Copy the base (2) to preserve it.
[>[>+>+<<-]>>[<<+>>-]<<<-]            Multiply what started as a 1 by the base.
>[-]>[<<+>>-]<<<<-                    Clean up and update loop counter.
]                                     End loop.
>>too golfy.                          Add some bytes, for all sequences <162 had been used. Print result.


Since this stores all Fibonacci numbers up to the important one, it will fail for REALLY big input on a bounded tape.

This could be shortened significantly by hardcoding the base (2), but golfiness isn't an issue at all.

• As the next answer (#346) broke the chain, your answer is the winner! – caird coinheringaahing Mar 14 '18 at 16:58
• @cairdcoinheringaahing Thank you for this amazing challenge. It saddens me that it should end now, but as do all good things in the world, end it did. Now to golf this poor excuse for code, for it's now the first answer anyone will see, and it must be impressively short... – Khuldraeseth na'Barya Mar 14 '18 at 18:23
• @Scrooble you can't really change the length... – NieDzejkob Mar 15 '18 at 14:22
• @NieDzejkob Yeah, but I can golf and add some more padding, to keep the same length. – Khuldraeseth na'Barya Mar 15 '18 at 15:25
• @cairdcoinheringaahing "broke the chain"? What does that mean? – Magic Octopus Urn Aug 2 '18 at 20:02

# 1. Triangular, 10 bytes, A000217

$\:_%i/2*<  Try it online! Next Sequence ## How it works The code formats into this triangle $
\ :
_ % i
/ 2 * <


with the IP starting at the $ and moving South East (SE, heh), works like this: $            Take a numerical input (n);     STACK = [n]
:           Duplicate it;                   STACK = [n, n]
i          Increment the ToS;              STACK = [n, n+1]
<         Set IP to W;                    STACK = [n, n+1]
*        Multiply ToS and 2ndTos;        STACK = [n(n+1)]
2       Push 2;                         STACK = [n(n+1), 2]
/      Set IP to NE;                   STACK = [n(n+1), 2]
_     Divide ToS by 2ndToS;           STACK = [n(n+1)/2]
\    Set IP to SE (heh);             STACK = [n(n+1)/2]
%   Output ToS as number;           STACK = [n(n+1)/2]
*  Multiply ToS by 2ndToS (no op); STACK = [n(n+1)/2]

• 1. Triangular, 10 bytes, A000217. *follows link* A000217 Triangular numbers ... – MD XF Jul 23 '17 at 3:39

# 2. Haskell, 44 bytes, A000010

f k|n<-k+1=length.filter(==1)$gcd n<$>[1..n]


Try it online!

Next Sequence

• The name of the next sequence though... – totallyhuman Jul 21 '17 at 15:16
• @totallyhuman poor rabbits... – Erik the Outgolfer Jul 21 '17 at 15:17
• Should we link to the previous post? – Leaky Nun Jul 21 '17 at 15:17
• It pains me that I cannot golf it now. I had to be first you see – BlackCap Jul 21 '17 at 15:20
• What is that next sequence? I don't understand the three ones :P – Beta Decay Jul 21 '17 at 15:20

# 3. JavaScript (ES6), 38 bytes, A000044

f=n=>n<0?0:n<3?1:f(n-1)+f(n-2)-f(n-13)


Try it online!

Next sequence (should be an easy one :P)

• "(should be an easy one :P)" it was – Erik the Outgolfer Jul 21 '17 at 15:24

# 4. Jelly, 2 bytes, A000038

ṆḤ


Try it online!

Next Sequence

• Noo, Kolakoski.... – Mr. Xcoder Jul 21 '17 at 15:24
• @Mr.Xcoder well that's why it's called a "challenge" – Erik the Outgolfer Jul 21 '17 at 15:24
• I deleted this because I don't want to use Jelly just yet; so much for that – Stephen Jul 21 '17 at 15:25
• And I even had f(x){return!x*2;} in ANSI C... – LegionMammal978 Jul 21 '17 at 15:26

# 5. Python 3, 72 bytes, A000002

n=int(input())
l=[1,2,2]
for i in range(2,n):l+=[1+i%2]*l[i]
print(l[n])


Try it online!

Next Sequence

• Gosh darn it, I was playing around with f=lambda n,r=1:n*(n<3)or 3-f(n-f(r),r+1) for around 40 bytes (works except f(3) is omitted), but my internet decided to bug out while I was playing around on TIO – ETHproductions Jul 21 '17 at 15:46
• I don't get what this sequence is about at all. Could someone explain it simply? – geokavel Jul 21 '17 at 15:47
• @geokavel See this challenge – Mr. Xcoder Jul 21 '17 at 15:49

# 6. R, 71 bytes, A000072

function(n)length(unique((t<-outer(r<-(0:2^n)^2,r*4,"+"))[t<=2^n&t>0]))


Try it online!

Next sequence

• For the love of God, I didn't check the next sequence before I posted this answer. – Leaky Nun Jul 21 '17 at 15:38
• Isn't an easy next sequence a strategic advantage? – BlackCap Jul 21 '17 at 15:39
• @BlackCap They can't answer twice in a row or less than 1 hour after they last answered. – Erik the Outgolfer Jul 21 '17 at 15:41
• @EriktheOutgolfer the answer before the last posted (the one who didn't break the chain) will win – BlackCap Jul 21 '17 at 15:41
• @BlackCap at this point that isn't going to happen – Stephen Jul 21 '17 at 15:42

# 7. Brain-Flak, 70 bytes, A000071

({}[<>((()))<>]){({}[()])<>({}<>)<>(({})<>({}<>))<>}<>{}{}({}<>{}[()])


Try it online!

Next sequence

## Explanation

({}[<>((()))<>]) #{ place a one on the off stack and subtract 1 from the input (to zero index)}
{({}[()])                          } #{n times}
<>({}<>)<>(({})<>({}<>))<>  #{Add the top two numbers in place}
<>{}{}({}<>{}[()]) #{Clean up and subtract 1}

• @cairdcoinheringaahing I don't know. Is that not allowed? – Sriotchilism O'Zaic Jul 21 '17 at 15:46
• no its fine. I just thought that it could help the next answerer – caird coinheringaahing Jul 21 '17 at 15:51

# 8. Mathematica (10.1), 25 bytes, A000070

Tr@PartitionsP@Range@#+1&


Next sequence

• The perfect sequence to use Mathematica for. – Leaky Nun Jul 21 '17 at 15:52
• A000025 is an incredibly difficult one. You should add a byte to get A000026 instead. :P – MD XF Jul 21 '17 at 16:29

# 9. Pyth, 19 bytes, A000025

?>Q0sm@_B1-edld./Q1


Next sequence

a(n) = number of partitions of n with even rank minus number with odd rank. The rank of a partition is its largest part minus the number of parts.

• For those who know Pyth, I deliberately used >Q0 instead of Q in order to, you know, have the next sequence to be A000019. – Leaky Nun Jul 21 '17 at 16:41
• From the OEIS page Keywords: easy,nice – BlackCap Jul 21 '17 at 16:46
• @LeakyNun Yeah since otherwise I'd have to solve A000017...gross. – Erik the Outgolfer Jul 21 '17 at 16:56

# 10. Magma, 65 bytes, A000019

f:=function(n);return NumberOfPrimitiveGroups(n+1);end function;


Try it here

lol builtin

Next sequence

• @ETHproductions :) no problem, thank the OEIS page though cuz it has the exact builtin there lol – HyperNeutrino Jul 21 '17 at 17:20
• ;_; I solved A000064 and you changed it. Downvoted. – Leaky Nun Jul 21 '17 at 17:26
• My gosh, so many partition sequences – ETHproductions Jul 21 '17 at 17:27
• I accidentally solved A007317 while trying to do this in Python (TIO) :P – ETHproductions Jul 21 '17 at 17:36
• Re-upvoted! \o/ – Leaky Nun Jul 21 '17 at 17:38

# 11. Pari/GP, 64 bytes, A000065

{a(n) = if( n<0, 0, polcoeff ( 1 / eta(x + x*O(x^n) ), n) - 1)};


Try it online!

Next sequence

• Is that valid input? – Leaky Nun Jul 21 '17 at 17:35
• Didya have to get 64 bytes? :P – totallyhuman Jul 21 '17 at 17:40
• @totallyhuman yes: ;_; I solved A000064 and you changed it. Downvoted. – Stephen Jul 21 '17 at 17:41
• @totallyhuman compromises lol. see chat – HyperNeutrino Jul 21 '17 at 17:41
• Dang – Mr. Xcoder Jul 21 '17 at 17:42

# 12. Java (OpenJDK 8), 131 bytes, A000064

int f(int n){int[]a=new int[n+1],c={1,2,5,10,1};a[0]=1;for(int i=0,j,k;i<5;i++)for(j=c[i],k=0;j<=n;j++,k++)a[j]+=a[k];return a[n];}


Try it online!

Next sequence

# 13. VB.NET (.NET 4.5), 1246 bytes, A000131

Public Class A000131
Public Shared Function Catalan(n As Long) As Long
Dim ans As Decimal = 1
For k As Integer = 2 To n
ans *= (n + k) / k
Next
Return ans
End Function
Shared Function Answer(n As Long) As Long

n += 7

Dim a As Long = Catalan(n - 2)

Dim b As Long = Catalan(n / 2 - 1)
If n Mod 2 = 0 Then
b = Catalan(n / 2 - 1)
Else
b = 0
End If

Dim c As Long = Catalan(n \ 2 - 1) ' integer division (floor)

Dim d As Long
If n Mod 3 = 0 Then
d = Catalan(n / 3 - 1)
Else
d = 0
End If

Dim e As Long = Catalan(n / 4 - 1)
If n Mod 4 = 0 Then
e = Catalan(n / 4 - 1)
Else
e = 0
End If

Dim f As Long = Catalan(n / 6 - 1)
If n Mod 6 = 0 Then
f = Catalan(n / 6 - 1)
Else
f = 0
End If

Return (
a -
(n / 2) * b -
n * c -
(n / 3) * d +
n * e +
n * f
) /
(2 * n)
End Function
End Class


A001246

Try it Online!

# 14. Python 2, 60 bytes, A001246

f=lambda x:x<1or x*f(x-1)
c=lambda n:(f(2*n)/f(n)/f(n+1))**2


Try it online!

Next sequence.

• Wow you ninja'd by 2 seconds – Business Cat Jul 21 '17 at 18:13

# 15. CJam, 85 bytes, A000060

{ee\f{\~\0a*@+f*}:.+}:C;2,qi:Q,2f+{_ee1>{~2*\,:!X*X<a*~}%{CX<}*W=+}fX_0a*1$_C.- .+Q)=  Online demo Next sequence ### Dissection OEIS gives G.f.: S(x)+S(x^2)-S(x)^2, where S(x) is the generating function for A000151. - Pab Ter, Oct 12 2005 where $$\begin{eqnarray*}S(x) & = & x \prod_{i \ge 1} \frac{1}{(1 - x^i)^{2s(i)}} \\ & = & x \prod_{i \ge 1} (1 + x^i + x^{2i} + \ldots)^{2s(i)}\end{eqnarray*}$$ { e# Define a block to convolve two sequences (multiply two polynomials) ee\f{ e# Index one and use the other as an extra parameter for a map \~\0a* e# Stack manipulations; create a sequence of index 0s @+f* e# Shift the extra parameter poly and multiply by the coefficient } :.+ e# Fold pointwise add to sum the polys }:C; e# Assign the block to C (for "convolve") 2, e# Initial values of S: S(0) = 0, S(1) = 1 qi:Q e# Read integer and assign it to Q ,2f+{ e# For X = 2 to Q+1 _ee1> e# Duplicate accumulator of S, index, and ditch 0th term { e# Map (over notional variable i) ~2*\ e# Double S(i) and flip i to top of stack ,:! e# Create an array with a 1 and i-1 0s X*X< e# Replicate X times and truncate to X values e# This gives g.f. 1/(1-x^i) to the first X terms a*~ e# Create 2S(i) copies of this polynomial }% {CX<}* e# Fold convolution and truncation to X terms W=+ e# Append the final coefficient, which is S(X), to the accumulator }fX _0a* e# Pad a copy to get S(X^2) 1$_C        e# Convolve two copies to get S(X)^2
.-          e# Pointwise subtraction
.+         e# Pointwise addition. Note the leading space because the parser thinks
e# -. is an invalid number
Q)=         e# Take the term at index Q+1 (where the +1 adjusts for OEIS offset)

• 1 minute and 33 seconds ahead of me... while I was typing the explanation – Leaky Nun Jul 21 '17 at 19:05

# 16. Lua, 69 bytes, A000085

function f(n)
if n<2 then return 1 end
return f(n-1)+~-n*f(n-2)
end


Try it online!

Next sequence

• Open problem: does Lua have memoization? This should have exponential complexity... – Leaky Nun Jul 21 '17 at 19:10
• Hold on, you 4 people \o/ – Leaky Nun Jul 21 '17 at 19:14

# 17. Stacked, 18 bytes, A000069

[bits  sum odd]nth


Try it online!

Next sequence. Pretty simple. Computes the number of bits, calculates the sum, then checks for odd parity. Then takes the nth such number. Hehehe good luck.

In retrospect, I could have made it 16 bytes instead of 17 or 18:

[bits sum 2%]nth


But oh well

• Next sequence is...? – Mr. Xcoder Jul 21 '17 at 19:20
• How are we supposed to do an erroneous sequence? – MD XF Jul 21 '17 at 19:20
• C'mon, you left us with the broken one??? – HyperNeutrino Jul 21 '17 at 19:21
• Fixing........... – Conor O'Brien Jul 21 '17 at 19:21
• Please change this one's byte cont, because the next one is broken – Mr. Xcoder Jul 21 '17 at 19:21

# 18. APL (Dyalog), 37 bytes, A000018

{+/(1↓∪,∘.{(⍵×⍵)+16×⍺×⍺}⍨⍳1+2*⍵)≤2*⍵}


Try it online!

Next sequence

Warning: this is terribly inefficent

• @ETHproductions Yes, forgot the number – Cows quack Jul 21 '17 at 20:03
• Note: I changed the bytecount of this solution to make it slightly easier for the next solution. cc @ETHproductions – Cows quack Jul 21 '17 at 20:06
• -1 for changing the next sequence for no good reason – Peter Taylor Jul 21 '17 at 20:09
• Oh, that'll probably be solved before I'm back at a computer then – ETHproductions Jul 21 '17 at 20:09

# 19. Curry, 45 bytes, A000037

f n=[x|x<-[1..],notElem x [y*y|y<-[1..x]]]!!n


Try it online

Next sequence

• ninja'd by 37 seconds >.< – HyperNeutrino Jul 21 '17 at 20:12
• but you were ninja'd by 23 seconds rip – HyperNeutrino Jul 21 '17 at 20:13

# 20. cQuents, 15 bytes, A000045

$0=0,1:z+y)))))  $0 means 0-indexed, =0,1 means it starts with 0,1, : means if given n it returns the nth item in the sequence, z+y means each item is the previous two added together. ))))) are no-ops due mostly to interpreter bugs.

Try it online!

Next sequence

# 21. M, 24 bytes, A000015

Ṫ*Ḣ
l2Rp²ÆR$µÇ€<³$ÐḟṂ
‘Ç


Try it online!

Next Sequence

Sorry for changing the next sequence; I had to fix my indexing.

## Explanation

Ṫ*Ḣ                !!!!!!! Helper Link
Ṫ                  Last element
*                 To the power of
Ḣ                First element
l2Rp²ÆR$µÇ€<³$ÐḟṂ  !!!!!!! Main Link
l2R                Range up to log_2(input); this is the largest power we need to handle because 2**k will be at least input this way
p               Cartesian Product with
²ÆR$All primes up to input squared µ New Monadic Link Ç€ Call the last link on each element (all prime powers) Ðḟ Filter to discard <³$                       elements smaller than the input
Ṃ  Minimum Value
‘                  Decrement


# 22. FiM++, 982 bytes, A000024

Note: if you are reading this, you might want to sort by "oldest".

Dear PPCG: I solved A000024!

I learned how to party to get a number using the number x and the number y.
Did you know that the number beers was x?
For every number chug from 1 to y,
beers became beers times x!
That's what I did.
Then you get beers!
That's all about how to party.

Today I learned how to do math to get a number using the number n.
Did you know that the number answer was 0?
For every number x from 1 to n,
For every number y from 1 to n,
Did you know that the number tmp1 was how to party using x and 2?
Did you know that the number tmp2 was how to party using y and 2?
Did you know that the number max was how to party using 2 and n?
tmp2 became tmp2 times 10!
tmp1 became tmp1 plus tmp2!
If tmp1 is more than max then: answer got one more.
That's what I did.
That's what I did.
That's all about how to do math.

PS:  This is the best answer
PPS: This really is the best answer


Next sequence

• Hahaha, laughed so hard through the whole thing. +1 for choice of language :-) – ETHproductions Jul 22 '17 at 13:49
• Amazing, take my upvote – downrep_nation Jul 23 '17 at 11:11

# 23. Ruby, 23 bytes, A000982

a=->(n){(n*n/2.0).ceil}


Try it online!

Next sequence

23rd entry uses 23 bytes!

• Could you format this as asked in the question please? – caird coinheringaahing Jul 21 '17 at 22:51
• fixed, sorry bout that – Justin Jul 21 '17 at 22:52

# 24. Julia 0.5, 33 bytes, A000023

Expansion of e.g.f. exp(−2*x)/(1−x).

!x=foldl((a,b)->a*b+(-2)^b,1,1:x)


Try it online!

Next sequence.

f x = sum $map f [2..n] where f k = g k div h k g k = (-1)^k * n * v (2*n-k-1) * v (n-k) h k = v (2*n-2*k) * v (k-2) v n = product [1..n] n = x+1  Try it online Next sequence • To quote the OP: You must wait for at least 1 hour before posting an answer, after having posted. This makes your answer invalid; you can ask OP in chat but I believe this invalidates your answer. – HyperNeutrino Jul 22 '17 at 0:09 • @HyperNeutrino My FiM++ answer was posted 22:28, this was posted 23:29 – BlackCap Jul 22 '17 at 0:13 • My bad. It must've rounded down to "1 hour" which is why I thought your FiM++ answer was younger than it was. Sorry for the misunderstanding :) – HyperNeutrino Jul 22 '17 at 0:15 • Reading through all answers here, and wondering how many essentially-haskell answers are coming still :p – tomsmeding Jul 23 '17 at 8:03 • @tomsmeding I still have idris and elm left – BlackCap Jul 23 '17 at 8:28 # 26. TI-BASIC, 274 bytes, A000183 .5(1+√(5→θ "int(.5+θ^X/√(5→Y₁ "2+Y₁(X-1)+Y₁(X+1→Y₂ {0,0,0,1,2,20→L₁ Prompt A Lbl A If A≤dim(L₁ Then Disp L₁(A Else 1+dim(L₁ (~1)^Ans(4Ans+Y₂(Ans))+(Ans/(Ans-1))((Ans+1))-(2Ans/(Ans-2))((Ans-3)L₁(Ans-2)+(~1)^AnsY₂(Ans-2))+(Ans/(Ans-3))((Ans-5)L₁(Ans-3)+2(~1)^(Ans-1)Y₂(Ans-3))+(Ans/(Ans-4))(L₁(Ans-4)+(~1)^(Ans-1)Y₂(Ans-4→L₁(Ans Goto A End  Evaluates the recursive formula found on the OEIS link. Next Sequence # 27. C++, 584 bytes, A000274 #include <map> #include <functional> using namespace std; int f(int i) { map<int, int> m; function<int(int)> a = [&](int j){ if (!m.count(j)) { switch (j) { case -1: case 0: m[j] = 0; break; case 1: m[j] = 1; break; case 2: m[j] = 3; break; default: m[j] = (1+j)*a(j-1)+(3+j)*a(j-2)+(3-j)*a(j-3)+(2-j)*a(j-4); } } return m[j]; }; return a(i - 1); }  Recursive solution with caching. Next Sequence (shouldn't be a tricky one) • Since now different compilers are considered different languages, I think you should specify which compiler you are using. – NieDzejkob Sep 23 '17 at 12:03 # 28. Positron, 9 bytes, A000584 ->{$1**5}


Try it online!

Finally got Positron in here ^_^

Next sequence

• Gosh darn it, I thought I had a chance to use Cubix, where the linear code is just I:***O@ – ETHproductions Jul 22 '17 at 0:51
• @ETHproductions :) Finally I managed to not get ninja'd... for once... lol – HyperNeutrino Jul 22 '17 at 0:52

## 29. JavaScript (SpiderMonkey), 46 bytes, A000009

f = function(n,q=1)n?n<q?0:f(n-q,q)+f(n,q+2):1


Try it online! The OEIS page is rather daunting, but after reading it for a while I realized that this boils down to the partitions problem, but using only odd integers. Change the q+2 to q+1 and you have a function that calculates the number of partitions of a number.

Next sequence. I tried hard to leave it off on an easy one, I really did...

• Please put a "29." in your header. I think you're confusing the Stack Snippet. – Silvio Mayolo Jul 22 '17 at 1:00
• @SilvioMayolo Ah sorry. This is my first time since #3, so I've already forgotten how to answer :P – ETHproductions Jul 22 '17 at 1:01
• @SilvioMayolo he made the stack snippet :P – Stephen Jul 22 '17 at 2:37