# 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:

1. NieDzejkob - 41 answers

2. KSmarts - 30 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

As with most questions, please format your answer like this

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

code

[next sequence](link)

*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.

## Answer chain snippet

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

# 147. Elixir, 695 bytes, A000121

defmodule A do
def p(n) do p(n,n,[]) end
def l(t,m,s) when m > 1 do p(t,m-1,s) end
def l(_,_,_) do [] end
def r(t,m,s) when m <= t do p(t-m,m,[m]++s) end
def r(_,_,_) do [] end
def p(0,_,s) do [s] end
def p(t,m,s) do l(t,m,s) ++ r(t,m,s) end

def f(n) do f(n,[1,1]) end
def f(n,l) do
if Enum.at(l, -1) >= n do l else
f(n, l ++ [Enum.at(l, -1) + Enum.at(l, -2)])
end
end

def n(l) do
Enum.sum Enum.map(l,fn n -> if n == 1 do 1 else 0 end end)
end

def a(0) do 1 end
def a(n) do
fb = f(n)
score = fn l -> if length(l -- fb) == 0 do if n(l) == 1 do 2 else 1 end else 0 end end
Enum.sum Enum.map(p(n), score)
end
end

{n,_} = Integer.parse IO.gets("")
IO.inspect A.a(n)


Try it online!

Next sequence!

# 151. Python 2, 31 bytes, A000125

lambda n:(n**3 + 5 * n + 6) / 6


Try it online!

Next sequence.

Alright, so the next one looks like an absolute doozy when you look at the title:

Number of n-bead necklaces with 2 colors when turning over is not allowed; also number of output sequences from a simple n-stage cycling shift register; also number of binary irreducible polynomials whose degree divides n.

Yeah... I dunno how people comprehend this stuff... But the formula doesn't look too bad.

a(n) = (1/n)*Sum_{ d divides n } phi(d)*2^(n/d), where phi is A000010.

Here's a Python 3 implementation:

import math

phi = lambda n: len([i for i in range(1, n + 1) if math.gcd(n, i) == 1])
A000031 = lambda n: n and sum(phi(d) * 2 ** (n / d) for d in range(1, n + 1) if n % d == 0) / n or 1


Try it online!

• Unfortunately, 29 bytes is unavailable. 31 is the lowest available score – caird coinheringaahing Sep 11 '17 at 15:07
• Sike, you thought. :P And yes, I do love my Python 2 for golfing. – totallyhuman Sep 11 '17 at 15:07

# 152. Mathics, 136 bytes, A000031

EulerPhi[x_] := Sum[If[CoprimeQ[i,x], 1, 0], {i, 1, x}]
OEIS[x_] := Sum[If[IntegerQ[x/d], (EulerPhi[d]*2^(x/d)), 0], {d,1,x}]/x
OEIS[#]&


Next Sequence.

Try it online!

This is just my previous Mathics answer, modified for the new sequence.

• Next one is quite the doozy - only 45 terms known, apparently – Stephen Sep 11 '17 at 17:14
• @Stephen I only looked at the title before posting this. I guess it's one of those deceptively simple problems. – KSmarts Sep 11 '17 at 17:31
• Those usually have a formula or at least a Mathematica program though :P – Stephen Sep 11 '17 at 17:33
• What have you done – NieDzejkob Sep 11 '17 at 17:50
• I believe one of the linked papers has a formula for the next one, except it's a sum over certain orders of the integers, which is quite nasty (page 13 of the doc, page 147 of the journal). At least we have almost every language available again; we won't have to do INTERCAL again for another hundred answers or so. – Giuseppe Sep 11 '17 at 17:54

# 155. Python 3, 83 bytes, A000262

a = lambda n: (2 * n - 1) * a(n - 1) - (n - 1) * (n - 2) * a(n - 2) if n > 1 else 1


Try it online!

Next sequence.

I shall starve this challenge of Python for the future. Fight me. ಠ_ಠ

...Also good luck with the next sequence. :P

• Comments are not for extended discussion; this conversation has been moved to chat. – Dennis Sep 24 '17 at 16:25
• ...but now I can't comment on my own post. ಠ_ಠ – totallyhuman Sep 24 '17 at 16:34

# 158. Jelly, 48 bytes, A000376

ḣ1‘Ṭœṗ
ÇḢU$;$F
ÇÐĿ
ṫ0ḢṢ⁼$‘RŒ!Q3Ŀ€ÇÐfL€Ṁ’¹¹¹¹¹¹¹  Try it online! # Explanation ḣ1‘Ṭœṗ Helper Link 1; splits the list into two sublists, the first of which is reversed ḣ1 First 1 element(s) without modifying the original list ‘ Increment Ṭ Generate a boolean list with 1s at the indices in (left) œṗ Partition, keeping borders ÇḢU$;$F Helper Link 2; applies 1 iteration of the TopSwop operation Ç Partition with length of the first element ḢU$;$Reverse the first list and concatenate it with the second list ḢU$                    Reverse the first list
Ḣ                      Head; modifies the list
U                     Reversed
;                   Concatenated with (the second list, implicit)
F                 Flatten
ÇÐĿ                     Helper Link 3; completes TopSwops for a list
ÐĿ                     While the results are unique (collects intermediate results)
Ç                       TopSwop once
ṫ0ḢṢ⁼$Helper Link 4; returns whether or not a list is sorted ṫ0 Last 0 sublists (gives the last one without modifying the original list) Ḣ Head; this unwraps the length 1 list of a single list Ṣ⁼$                  Is it sorted?
Ṣ                    The list sorted
⁼                   equals (the original list, implicit) (non-vectorizing)
‘RŒ!Q3Ŀ€ÇÐfL€Ṁ’¹¹¹¹¹¹¹  Main Link
‘                       Increment (for 0-indexing)
R                      Range
Œ!                    All permutations (with duplicates)
Q                   Deduplicate (technically unnecessary)
€                For each sublist
3Ŀ                 Apply Helper Link 3; completes TopSwops
Ðf             Keep sublists where
Ç               The end result is sorted
€           For each element
L            Yield its length
Ṁ          Get maximum length
’         Decrement because the first "iteration" is the beginning list
¹¹¹¹¹¹¹  Identity function chained 7 times; has no effect in this situation


Next Sequence - More necklaces yay

# 159. Java (OpenJDK 8), 778 bytes, A000048

import java.util.Scanner;
import java.math.BigInteger;

public class Main {
static boolean isPrime(int n){
if(n % 2 == 0) return n == 2;
for(int d = 3;d*d <= n;d += 2){
if(n % d == 0) return false;
}

return true;
}

static int mu(int n){
int r = 1;
for(int p = 2;p <= n;p++){
if(!isPrime(p) || n % p != 0) continue;
if(n % (p*p) == 0) return 0;
r = -r;
}

return r;
}

static BigInteger a(int n){
if(n == 0) return BigInteger.ONE;
BigInteger s = BigInteger.ZERO;
for(int d = 1;d <= n;d += 2){
if(n % d == 0) s = s.add(BigInteger.valueOf(mu(d)).shiftLeft(n / d));
}

return s.divide(BigInteger.valueOf(2 * n));
}

public static void main(String args[]){
int n = new Scanner(System.in).nextInt();
System.out.println(a(n));
}
}


Try it online!

Next sequence!

# 163. R, 227 bytes, A000448

A000448 <- function(n){
if(n == 0)
return(0)
k <- 1
l <- (0:k)^2
g <- table(combn(l,2,sum))
while(max(g) < n+1){
k <- k+1
l <- c(l,k^2)
g <- table(combn(l,2,sum))
}
min(as.numeric(names(g[g>n])))
}


Try it online!

Next Sequence

Brute force approach! Takes sums of unordered pairs of squares, combn(l,2,sum), tabulates them with table to get counts, and then iterates until it finds one that can be written as the sum of squares in n+1 ways (so it's zero-indexed). Then it extracts the names, converts them to numeric, and selects the min. This will lose precision after about n = 64, at which point (most) R implementations would convert the sums to doubles. That could be saved by using a bigz implementation but that's not what we have to do here.

It also times out on TIO for n=10 because this is slow as all get-out.

# 173. Python 2 (IronPython), 257 bytes, A000055

c={0:0,1:1}
def b(n):
if n not in c:c[n]=sum([sum([d*b(d)for d in range(1,j+1)if j%d==0])*b(n-j)for j in range(1,n)])//(n-1)
return c[n]
def a(n):return 1if n==0 else b(n)-(sum([b(k)*b(n-k)for k in range(n)])-(b(n//2)if n%2==0 else 0))//2
print a(input())


Try it online!

Next sequence!

2 versions of Python on the wall, 2 versions of Python. Take one down and pass it around, 1 version of Python on the wall.

Caches the results of b because it seemed like it would take forever to compute for big n without it. Didn't test whether it does anything useful, but it probably does.

# 175. PHP, 122 bytes, A000054

<?php
$n=file_get_contents('php://stdin');$s=0;for($i=0;$i<=$n;$i++){$s+=ord("DJIKHHIMIEJGGFIJJJHEGFIJG"[$i])-64;}echo $s;  Try it online! Next sequence! Uses delta encoding with the deltas represented by uppercase ASCII characters. The next sequence looks intimidating but it's just 1 at 0, 2 if sqrt(n) is an integer and 0 otherwise. • Note that hardcoding for less than 1000 digits is completely fine in this case, since this is a finite sequence, not an infinite one. – Stephen Sep 22 '17 at 12:49 • @Stephen unless someone says that this should scrape the subway's website ;) – NieDzejkob Sep 22 '17 at 12:50 • @NieDzejkob and OEIS has a broken link... – KSmarts Sep 22 '17 at 14:29 # 177. Lua, 214 bytes, A000184 function v(n)if n<1then return 1 end return v(~~~-n)*n end function V(n)if n<1then return 1 end return V(~-~-n)*n end function F(n)return math.floor(1/12*(2^(-~-~n+1)*V(-~(-~-~n<<1))/v(-~-~n-1)-3*4^-~-~n*-~-~n))end  • dang, I was just testing out my PicoLisp implementation for this one, but it wasn't working on TIO...It's actually much simpler than the Maple implementation; using some gamma function identities, the formula provided by Mark van Hoeij simplifies to 2/3*GAMMA(2n)*(n+1/2)/(GAMMA(n)^2)-n*4^(n-1) where GAMMA(x)=factorial(x-1) – Giuseppe Sep 22 '17 at 13:29 • Gotta love easy tagged sequences without a formula – Stephen Sep 22 '17 at 13:30 • Come on! easy but no formula and no program, two out of three links are dead. – NieDzejkob Sep 22 '17 at 13:51 • Good news is that the dead links are archived on web.archive.org – NieDzejkob Sep 22 '17 at 13:54 # 179. C (clang), 62 bytes, A000933 f(n){double c=(n>2)*~-~-n*~-~-~-n/3./4;return c+(c-(int)c>0);}  # 180. C (tcc), 63 bytes, A000062 #include <math.h> int a(int n){ return (n + 1) / (M_E - 2); }  Try it online! Next sequence! Now since there is a lot of C versions, C must get the same treatment as Python. # 181. C (clang), 276 bytes, A000063 long Factorial(n){return n<2?1:n*Factorial(n-1);} Choose(n,k){return Factorial(n)/Factorial(k)/Factorial(n-k);} Catalan(double n){return n-(int)n?0:(int)(1/(n+1.)*Choose(2*n,n));} A000063(n){return Catalan(-~-~-~-~-~n/2-1)-Catalan(-~-~-~-~-~n/4.-1)-Catalan(-~-~-~-~-~n/6.-1);}  • Wait wasn't clang used for 180? – Husnain Raza Sep 23 '17 at 18:01 • @HusnainRaza but it wasn't used in the first 150 answers. On TIO there are 3 C compilers, so we can have at least 6 C answers. Yes, it's dumb, but valid. – NieDzejkob Sep 23 '17 at 18:11 # 182. Common Lisp, 134 bytes, A000276 (defun fact(n) (if (< n 2) 1 (* n (fact (1- n))))) (defun a(n) (* (fact (+ n 3)) (1- (loop for k from 1 to (+ n 2) summing (/ 1 k)))))  Trival use of the formula specified by Detlefs on the OEIS page Try it online! Next sequence • Think this answer is invalid due to repeated language of last answer :( – Husnain Raza Sep 23 '17 at 18:04 • @HusnainRaza this is the second time Common Lisp has been used, that's OK – Stephen Sep 23 '17 at 18:16 • @Stephen this is probably not what he meant but this is still valid – NieDzejkob Sep 23 '17 at 18:17 • I think what he was trying to say is that this is invalid because it is chaining off answer 181, which is invalid because of language repeats. Still, that doesn't seem to be true. – pppery Sep 23 '17 at 19:35 # 183. PostL, 61 bytes, A000134 INPUT PARSE 1 + C 3.1416 * 0.290498\ - FLR \ 1 \ 0 \ 2 - = +.  Try it online! Next Sequence _ is supposed to work in place of floor (or flr) but apparently it doesn't... hm # Walkthrough INPUT PARSE 1 + C 3.1416 * 0.290498\ - FLR \ 1 \ 0 \ 2 - = +. A000134 INPUT Take a line of input PARSE Parse to a double 1 Push 1 + Add top two elements C Copy the zero-indexed number 3.1416 ~pi * Multiply top two elements 0.290498 Thanks to Husnain Raza for this magic number \ Swap the top two elements - Subtract the second from the top FLR Floor \ Swap top two 1 Push 1 \ Swap top two 0 Push 0 \ Swap top two 2 Push 2 - Subtract the second from the top = Switch: 1 if x == 2 else 0 +. Add top two and print  • For 999 this returns 3142, but it should be 3141 – Christian Sievers Sep 23 '17 at 19:53 • Where did you get that formula? – NieDzejkob Sep 23 '17 at 20:19 • the formula round(3.1416*n-0.790498) works for all n for 2<n<1000 – Husnain Raza Sep 23 '17 at 22:05 • @HusnainRaza Thanks for the revised formula edit it doesn't work for 1 -> 6 edit fixed – HyperNeutrino Sep 23 '17 at 23:49 • @NieDzejkob, if you look at the Shanks paper, I think that line is supposed to correspond to equation 16, but it's missing an exponent of 2n. It also seems to simplify considerably to d(a,n) = d(b,n) m^(4n-1) prod_{p_i|m} (1 - jacobi(b, p_i) p_i^{-2n}) – Peter Taylor Sep 24 '17 at 22:12 # 186. axo, 177 bytes, A000017 10=01=02=23=24=45=86=47=82*8=43*9=68*25*=825**25*1+=89+8*26*=725**6*[26*1+=][2*55*2*8*+[27*=][2*778**+[35*=][2*26*1+4*1+9*4*+[44*=][2*55447****+[44*1+=][3*288**1+84**-29*= }={ \  Try it online! I'm aware that hardcoding is apparently "lame" but this took me like half an hour so I'm not gonna trash it ;P This essentially hardcodes all of the values and puts them into the memory, then uses the = function to read the specific memory address and output it. Next Sequence # 187. SageMath, 321 bytes, A000177 import sage.combinat.partition var('t', 's', 'isSquare') def A000177(n): t = Partitions(n).list() s = 0 for i in range(len(t)): if len(t[i])>6: continue isSquare = True for j in range(len(t[i])): if sqrt(t[i][j]) not in ZZ: isSquare = False if isSquare: s = s+1 return s  Next Sequence You can try it here. # 192. Emoji, 326 bytes, A001824 📥👥🔚📤💬t💬📲💬1💬📥👥💬10💬📥🔀📤⛽👥💬t💬📱🐣🚘⛽👥💬n💬📲🔀👥💬a💬📲🔀👥👪💬4💬📥👪📤👥👫👪🔀💬n💬📱👥👫💬1💬📥🌊👥👪👥👪👪🌊💬a💬📱🔀💬n💬📱📤🚘🔃🔚🐧🐧🔙💬1💬📥🐧➡  Try it online! Next sequence! Abuses 📥 (floor) to convert a string to a number and 📤 (ceil) to increment. Also uses ints instead of booleans in conditionals, but the interpreter does seems to be okay with it. Uses the following formula: a(n) = 2*(4*n^2+1)*a(n-1) - (2*n-1)^4*a(n-2). The program operates on integers, but the language specification looks like only floats were supposed to be available. This allows computing the sequence infinitely without accuracy problems as the interpreter is implemented in Python. # 197. D, 347 bytes, A000056 import std.stdio, std.conv; void main(string[] args){ int n = to!int(readln)+1; double x = 1; for(int i=2; i<n; i++){ bool prime = true; for(int k=2; prime && k<=i/2; k++) { if(i%k==0) { prime=false; } } if(prime && n%i==0) { x = x*(1-1/(cast(double)i*i)); } } writeln(n*n*n*x); }  Try it online! Next Sequence. Uses the formula a(n)=n*A007434(n), and the formula A007434(n) = n^2*Product_{p|n}(1-1/p^2). • Crude implementation of the next sequence in Python. It's ridiculously inefficient though. – totallyhuman Oct 2 '17 at 16:58 • @icrieverytim That's because you wrote it in Python. – KSmarts Oct 2 '17 at 17:19 • Oi, what do you get out of bashing Python for its speed? :P In any case, I realized I know all C-style languages to some extent, so I'm porting my solution to Go. Please don't ninja me, I'm on mobile. ;-; – totallyhuman Oct 2 '17 at 17:27 # 198. Go, 466 bytes, A000347 import . "math" func A000347(n float64) int { result := 0 n += 4 for x_1 := 1.0; x_1 < n * n; x_1++ { for x_2 := x_1; x_2 < n * n; x_2++ { for x_3 := x_2; x_3 < n * n; x_3++ { for x_4 := x_3; x_4 < n * n; x_4++ { if Sqrt(x_1) + Sqrt(x_2) + Sqrt(x_3) + Sqrt(x_4) <= n { result += 1 } } } } } return result }  Try it online! Next sequence. (Easy.) # 203. Julia 0.5, 96 bytes, A000050 function A000050(n) x = 0:(2^n) y = x' z = x.^2 .+ y.^2 z = z[z .<= 2^n] length(unique(z))-1 end  Try it online! Next Sequence Needs the -1 in length(unique(z))-1 because it always includes 0, which is not a positive integer. # 216. BeanShell, 411 bytes, A000095 J(a,b){if(b<=0||(b%2)==0) return 0;j=1;if(a<0){a=-a;if((b%4)==3)j=-j;}while(a!=0){while((a%2)==0){a/=2;if((b%8)==3||(b%8)==5)j=-j;}t=a;a=b;b=t;if((a%4)==3&&(b%4)==3)j=-j;a=a%b;}if(b==1)return j;return 0;}n=new Scanner(System.in).nextInt()+1;l=(n==1)?1:0;if(n%4>0){l=(n%2>0)?1:2;for(d=3;d<=n;d+=2){if(n%d>0)continue;P=true;for(p=3;p*p<=d;p+=2)if(d%p==0){P=false;break;}if(!P)continue;l=l*(1+J(-1, d));}}print(l);  Also prints the input for some reason. I don't think it's possible to fix it Try it online! Next sequence! # 230. Cubix, 86 bytes, A001147 ................I?1O@.../s;.\...........*...............p..W/..../......?-2q:(*2O..W\p  Try it online! Next sequence Expands to the cube:  . . . . . . . . . . . . . . . . I ? 1 O @ . . . / s ; . \ . . . . . . . . . . . * . . . . . . . . . . . . . . . p . . W / . . . . / . . . . . . ? - 2 q : ( * 2 O . . W \ p . . . . . . . . . .  • @NieDzejkob 86 byte answer just so we can all see your opus magnum. – Giuseppe Oct 20 '17 at 14:56 # 239. Boo, 346 bytes, A000429 import System.Numerics def f(n as long,k as long): p=BigInteger(1);for i in range(n,n-k):p*=i if k>1: for i in range(k,1):p/=i return p def b(n as long,i as long,k as long)as long: s=0;if n<1:return 1 if i<1or k<1:return 0 t=b(i-1,i-1,k-1);for j in range(0,n/i+1):s+=f(t+j-1,j)*b(n-i*j,i-1,k) return s def a(n): return b(n,n,8)-b(n,n,7)  Next sequence! Try it online! # 285. Squirrel, 151 bytes, A000211 function A000211(input) { if(input==0){ return 4; } if(input==1){ return 3; } if(input==2){ return 5; } return (A000211(input-1)+A000211(input-2)-2); }  Try it online! Didn't take much to learn this language! Next Sequence! # 282. Actually, 126 bytes, A011628 29*7+9*8+╝╛@%╗╜0=⌠00.ó⌡n10-1╛R⌠²╛@%╜=⌡cI"Did you know that Vim is vastly superior to every other existing editor? #flamewars"X  Try it online! Next sequence! ### Explanation 29*7+9*8+╝╛@%╗╜0=⌠00.ó⌡n10-1╛R⌠²╛@%╜=⌡cI 29*7+9*8+╝ Put 233 in the second register ╛@%╗ Calculate input%233 and put it in the first register (I'll call this n) ╜0=⌠00.ó⌡n If n is 0, output 0 and exit ╛R⌠ ⌡c Count integers smaller or equal to 233... ² such that their squares ╛@% are congruent modulo 233 ╜= to the input. I If there is at least one such integer (i. e. n is a quadratic residue mod 233) 1 then output 1, 10- otherwise, output -1  • The resut for n=2 seems wrong (and from the description, I don't understand how it gets the right result for n=7) – Christian Sievers Dec 24 '17 at 18:30 • Unintuitive operand order got me during a last minute change... hang on – NieDzejkob Dec 25 '17 at 9:26 • The explanation claims you count how many numbers <=n have square congruent to n. I guess that's really something like <=233. (BTW, there will always be two square roots.) – Christian Sievers Dec 25 '17 at 10:49 • @ChristianSievers that's right, I made a mistake when rereading the code, fixed ;) – NieDzejkob Dec 25 '17 at 11:59 # 286. Pyon, 1118 bytes, A000151 from fractions import Fraction def tofrac(a): global Fraction return [Fraction(x) for x in a] # a(x)*b(x), first n terms def mul(a, b, n): x=[0] * min(n, len(a) + len(b) - 1) for i in range(min(n, len(a))): for j in range(min(n - i, len(b))): x[i + j] += a[i] * b[j] return x # a(x^e), first n terms def powarg(a, e, n): return [0 if i % e else a[i // e] for i in range(n)] # c*a(x) def mulc(a,c): return [x * c for x in a] def divcfrac(a,c): return [x / c for x in a] # a(x) + b(x) def add(a,b): return [(a[i] if i < len(a) else 0) + (b[i] if i < len(b) else 0) for i in range(max(len(a), len(b)))] # a'(x) def polyderiv(a): return [i * x for i, x in enumerate(a)][1:] # f(x)*exp(g(x)), coefficient of x^n def exptaylor(f,g,n): global add, polyderiv, mul fac = 1 for i in range(n): f=add(polyderiv(f), mul(f, polyderiv(g), n)) fac *= i + 1 return f[0].numerator // fac R = [0, 1] for n in range(len(R), int(input()) + 2): P = [] for k in range(1, n): d = divcfrac([Fraction(x) for x in powarg(R, k, n)], k) P = add(P, d) R.append(exptaylor([0, 1], mulc(P, 2), n)) print(R[-1])  Try it online! Next sequence! # 288. Swift 4, 186 bytes, A007437 func divisors(_ n: Int) -> [Int]{ return Array(1...n).filter{n %$0 < 1}
}

func A007437(_ n: Int) -> Int{
var summ = 0
for i in divisors(n + 1){
summ += i*(i+1)/2
}
return summ
}


Try it online!

Next Sequence: Number of 3 by n Latin rectangles in which the first row is in order.

# 291. Whispers, 130 bytes, A000337

> Input
> 1
> 2
>> 1-2
>> 3*1
>> 4×5
>> 6+2
>> Output 7
As usual, padding is required
to make this a valid answer
Whispers rules!


Try it online!

Next sequence

# 293. Commodore 64 BASIC, 431 bytes, A000132

10 R=0
20 INPUT N
30 FOR A=0 TO FLOOR(SQR(N))
40 F=N-A*A
50 FOR B=0 TO FLOOR(SQR(F))
60 G=F-B*B
70 FOR C=0 TO FLOOR(SQR(G))
80 H=G-C*C
90 FOR D=0 TO FLOOR(SQR(H))
100 L=H-D*D
110 E=FLOOR(SQR(L))
120 IF E*E<>L GOTO 200
130 Z=1
140 IF A<>0 THEN Z=Z*2
150 IF B<>0 THEN Z=Z*2
160 IF C<>0 THEN Z=Z*2
170 IF D<>0 THEN Z=Z*2
180 IF E<>0 THEN Z=Z*2
190 R=R+Z
200 NEXT D
210 NEXT C
220 NEXT B
230 NEXT A
240 PRINT R


Next sequence!

Sorry, but no TIO link this time. This will have to do:

(bytecount measured according to this meta post)