One OEIS after another

95

27

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>

caird coinheringaahing

Posted 2017-07-21T15:00:01.030

Reputation: 13 702

Comments are not for extended discussion; this conversation has been moved to chat.

– Dennis – 2017-10-31T02:49:10.023

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 – 2017-11-21T15:15:01.370

@NieDzejkob Assuming that it was only limited by memory and/or time, and would theoretically work if given infinite time and memory, then yes. – caird coinheringaahing – 2017-11-21T15:42:31.600

@cairdcoinheringaahing that's not what I'm talking about, check the most recent (swift) answer. – NieDzejkob – 2017-11-21T15:55:18.197

@NieDzejkob In that case, yes it's acceptable, as the problem isn't with the program. – caird coinheringaahing – 2017-11-21T15:56:57.570

The problem is with the program, though. It's failing to accurately calculate intermediate values which are within the bounds of its types. – Peter Taylor – 2017-11-21T16:27:35.013

@PeterTaylor Sorry, I'm unfamiliar with Swift. If the problem truly is with the answer, and can be corrected, then the answer is invalid. – caird coinheringaahing – 2017-11-21T16:31:23.400

with regards to the hardcoding, I commented here with a rational approximation for gamma that's precise enough to get the first 1001 terms of the continued fraction representation, because it's the rational number represented by the first 1001 terms. Would that count as "hardcoding the sequence"?

– Giuseppe – 2017-12-15T22:12:21.603

1@Giuseppe No, as you're generating the numbers by doing the maths, rather than just placing them into an array/string – caird coinheringaahing – 2017-12-15T22:14:18.347

2@cairdcoinheringaahing In my opinion that's hardcoding the gamma constant. It doesn't work "in theory" for larger numbers. – user202729 – 2017-12-22T12:44:09.580

6Chat room – user202729 – 2017-12-22T12:45:17.147

Should ... there is no good in deleted the chain up to ... not rather read ... there is no good in deleting the chain up to ... or something similar? – Jonathan Frech – 2018-01-28T17:08:33.417

@JonathanFrech Yes it should, corrected. – caird coinheringaahing – 2018-01-28T17:09:40.850

Answers

4

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. 
  <<[>>+>+<<<-]>>>[<<<+>>>-]            Add fib(n-2)...
  <<[>+>+<<-]>>[<<+>>-]                 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.

Khuldraeseth na'Barya

Posted 2017-07-21T15:00:01.030

Reputation: 2 608

As the next answer (#346) broke the chain, your answer is the winner! – caird coinheringaahing – 2018-03-14T16:58:29.643

1@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 – 2018-03-14T18:23:53.330

@Scrooble you can't really change the length... – NieDzejkob – 2018-03-15T14:22:57.383

@NieDzejkob Yeah, but I can golf and add some more padding, to keep the same length. – Khuldraeseth na'Barya – 2018-03-15T15:25:31.803

@cairdcoinheringaahing "broke the chain"? What does that mean? – Magic Octopus Urn – 2018-08-02T20:02:14.087

40

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.
Then you get answer!
That's all about how to do math.

Your faithful student, BlackCap.

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

Next sequence

BlackCap

Posted 2017-07-21T15:00:01.030

Reputation: 3 576

10Hahaha, laughed so hard through the whole thing. +1 for choice of language :-) – ETHproductions – 2017-07-22T13:49:38.683

Amazing, take my upvote – downrep_nation – 2017-07-23T11:11:35.720

22

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]

caird coinheringaahing

Posted 2017-07-21T15:00:01.030

Reputation: 13 702

13>

  • Triangular, 10 bytes, A000217. *follows link* A000217 Triangular numbers ...
  • < – MD XF – 2017-07-23T03:39:23.403

    22

    73. Starry, 363 bytes, A000252

    , +      + *     '.     `
     + + + +  *  *  *  +     
     +`      +*       +    ` 
     + +   +  + +   + *  '   
       +   '  ####`  + +   + 
     + +    ####  +*   +    *
        '  #####  +      + ' 
      `    ######+  + +   +  
    + +   + #########   * '  
     +   +  + #####+ +      +
    *  +      + * +  *  *   +
       +  *  + + + +  *  *   
    +   +  +   *   + `  + +  
     +  + +   + *'    +    +.
    

    Try it online!

    Next sequence

    Uses the formula "a(n) = n^4 * product p^(-3)(p^2 - 1)*(p - 1) where the product is over all the primes p that divide n" from OEIS.

    The moon's a no-op, but hey, this isn't code-golf.

    Not a tree

    Posted 2017-07-21T15:00:01.030

    Reputation: 3 106

    stars in moon? hmmm – betseg – 2018-01-01T14:45:00.630

    19

    97. Python 3 (PyPy), 1772 bytes, A000236

    First of all, many thanks to Dr. Max Alekseyev for being patient with me. I'm very fortunate that I was able to contact him by email to understand this challenge. His Math.SE answer here helped me out a lot. Thanks to Wheat Wizard for helping me as well. :)

    plist = []
    
    def primes(maximal = -1): # Semi-efficient prime number generator with caching up to a certain max.
    	index = plist and plist[-1] or 2
    	for prime in plist:
    		if prime <= maximal or maximal == -1: yield prime
    		else: break
    	while index <= maximal or maximal == -1:
    		composite = False
    		for prime in plist:
    			if index % prime == 0:
    				composite = True
    				break
    		if not composite:
    			yield index
    			plist.append(index)
    		index += 1
    
    def modinv(num, mod): # Multiplicative inverse with a modulus
    	index = 1
    	while num * index % mod != 1: index += 1
    	return index
    
    def moddiv(num, dnm, mod):
    	return num * modinv(dnm, mod) % mod
    
    def isPowerResidue(num, exp, mod):
    	for base in range(mod):
    		if pow(base, exp, mod) == num:
    			return base
    	return False
    
    def compute(power, prime):
    	for num in range(2, prime):
    		if isPowerResidue(moddiv(num - 1, num, prime), power, prime):
    			return num - 1
    	return -1
    
    # file = open('output.txt', 'w')
    
    def output(string):
    	print(string)
    	# file.write(str(string) + '\n')
    
    def compPrimes(power, count):
    	maximum = 0
    	index = 0
    	for prime in getValidPrimes(power, count):
    		result = compute(power, prime)
    		if result > maximum: maximum = result
    		index += 1
    		# output('Computed %d / %d = %d%% [result = %d, prime = %d]' % (index, count, (100 * index) // count, result, prime))
    	return maximum
    
    def isValidPrime(power, prime):
    	return (prime - 1) % power == 0
    
    def getValidPrimes(power, count):
    	collected = []
    	for prime in primes():
    		if isValidPrime(power, prime):
    			collected.append(prime)
    		if len(collected) >= count:
    			return collected
    		# output('Collected %d / %d = %d%% [%d]' % (len(collected), count, (100 * len(collected)) // count, prime))
    
    power = int(input()) + 2
    
    output(compPrimes(power, 100))
    
    # file.close()
    

    Try it online!

    If it gives the wrong result, just increase the 100 to something larger. I think 10000 will work for 4 but I'll leave my computer running overnight to confirm that; it may take a couple of hours to finish.

    Note that the (PyPy) part is just so that I can use Python again. I really don't know many other languages and I'm not going to try to port this to Java and risk not finishing in time.

    Next Sequence (Also please don't do any more crazy math stuff; I don't have any Python versions left so someone else will have to save this challenge D:)

    HyperNeutrino

    Posted 2017-07-21T15:00:01.030

    Reputation: 26 575

    well there's always pypy3 – ASCII-only – 2017-08-06T04:29:27.040

    15

    107. TrumpScript, 1589 bytes, A000047

    My cat hears everything really well
    because with me every cat is a safe cat
    Everybody knows that one is 1000001 minus 1000000
    but only most of you that two is, one plus one;
    As always nothing is, one minus one;
    My dog is one year old.
    I promise you that as long as you vote on me, nothing will be less cool than a cat;:
    Much dog is, dog times two;
    Dead cat is, cat minus one;!
    I will make dog feel good, food for dog plus one;
    Roads can be made using different things. Asphalt is one of them.
    As long as Hillary jailed, I love asphalt less than my dog;:
    Roads are, always made using asphalt plus one of other things;
    I promise my roadways are, two times asphalt than you want;
    My roadways are great, always roadways plus one;
    Vladimir is nothing more than my friend.
    Name of Putin is Vladimir.
    As long as, Putin eat less roadways;:
    China is nothing interesting.
    We all know people speaking Chinese are from China.
    As long as, Chinese makes less roads;:
    I will make economy, for Putin - Chinese will love me;
    If it will mean, economy is asphalt in Russia?;:
    I will make cat feel good, cat plus one dollar on food;
    Make Vladimir roadways to help Russia economy.
    Never make china roads!
    I show you how great China is, China plus one; You can add numbers to China.
    Like Chinese is, China times China makes sense;
    Like Chinese is, two times Chinese letter;!
    Make Vladimir happy, Vladimir plus one million dollars;
    I also show you how great Putin is, Vladimir times Vladimir; You can do number stuff to Putin too!
    I will make asphalt roads a lot!
    Everybody say cat. You did it? America is great.
    

    Try it online!

    First time programming in TrumpScript, it is possible that I reinvented the wheel a few times - 4 lines are dedicated to calculating 2 ^ n. I tried to make it look like something that (drunk) Trump could say. As a bonus, here is a Python script I wrote to verify that I'm doing everything right. There are some differences to the above program, but much of it is directly equivalent.

    cat = int(input())
    dog = 2 ** cat + 1
    asphalt = 1
    cat = 0
    while asphalt < dog:
        roads = asphalt + 1
        roadways = 2 * asphalt + 1
        vladimir = 0
        putin = vladimir
        while putin < roadways:
            china = 0
            chinese = china
            while chinese < roads:
                chair = putin - chinese
                if chair == asphalt:
                    cat += 1
                    vladimir = roadways
                    china = roads
                china += 1
                chinese = 2 * china * china
            vladimir += 1
            putin = vladimir * vladimir
        asphalt = roads
    print(cat)
    

    Next sequence!

    NieDzejkob

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 630

    3I will make cat feel good O_O – Business Cat – 2017-08-15T16:20:48.887

    Sadly I will make Business Cat feel good won't work... – NieDzejkob – 2017-08-15T16:26:45.453

    14

    30. Python 1, 1112 bytes, A000046

    def rotations(array):
    	rotations = []
    	for divider_index in range(len(array)):
    		rotations.append(array[divider_index:] + array[:divider_index])
    	return rotations
    
    def next(array):
    	for index in range(len(array) - 1, -1, -1):
    		array[index] = 1 - array[index]
    		if array[index]: break
    	return array
    
    def reverse(array):
    	reversed = []
    	for index in range(len(array) - 1, -1, -1):
    		reversed.append(array[index])
    	return reversed
    
    def primitive(array):
    	for index in range(1, len(array)):
    		if array == array[:index] * (len(array) / index): return 1
    	return 0
    
    def necklaces(size):
    	previous_necklaces = []
    	array = [0] * size
    	necklaces = 0
    	for iteration in range(2 ** size):
    		if not primitive(array) and array not in previous_necklaces:
    			necklaces = necklaces + 1
    			for rotation in rotations(array):
    				complement = []
    				for element in rotation:
    					complement.append(1 - element)
    				previous_necklaces.append(rotation)
    				previous_necklaces.append(complement)
    				previous_necklaces.append(reverse(rotation))
    				previous_necklaces.append(reverse(complement))
    		array = next(array)
    	return necklaces
    

    Try it online!

    Not even going to bother to golf this. Hey, it's not my longest Python answer on this site!

    Next sequence

    HyperNeutrino

    Posted 2017-07-21T15:00:01.030

    Reputation: 26 575

    1Congratulations on decoding the maths :D – Leaky Nun – 2017-07-22T04:27:18.713

    2313 bytes, lol – Leaky Nun – 2017-07-22T04:57:41.890

    @LeakyNun As I was saying, I didn't bother to golf this lol. Besides, it's not my longest Python answer on this site so idc :P but nice – HyperNeutrino – 2017-07-22T15:16:44.443

    @LeakyNun And thanks :D It took me a while to understand all of it lol – HyperNeutrino – 2017-07-22T16:22:04.163

    @LeakyNun 309 bytes because the actual value of _ is irrelevant; we just need to repeat that many times

    – HyperNeutrino – 2017-09-24T01:36:48.527

    305 bytes using the same trick – Leaky Nun – 2017-09-24T07:30:24.367

    13

    2. Haskell, 44 bytes, A000010

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

    Try it online!

    Next Sequence

    BlackCap

    Posted 2017-07-21T15:00:01.030

    Reputation: 3 576

    12The name of the next sequence though... – totallyhuman – 2017-07-21T15:16:01.607

    @totallyhuman poor rabbits... – Erik the Outgolfer – 2017-07-21T15:17:13.887

    Should we link to the previous post? – Leaky Nun – 2017-07-21T15:17:29.740

    It pains me that I cannot golf it now. I had to be first you see – BlackCap – 2017-07-21T15:20:32.813

    What is that next sequence? I don't understand the three ones :P – Beta Decay – 2017-07-21T15:20:40.483

    13

    9. Pyth, 19 bytes, A000025

    ?>Q0sm@_B1-edld./Q1
    

    Test suite.

    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.

    Leaky Nun

    Posted 2017-07-21T15:00:01.030

    Reputation: 45 011

    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 – 2017-07-21T16:41:24.610

    1From the OEIS page Keywords: easy,nice – BlackCap – 2017-07-21T16:46:56.407

    @LeakyNun Yeah since otherwise I'd have to solve A000017...gross. – Erik the Outgolfer – 2017-07-21T16:56:16.583

    12

    8. Mathematica (10.1), 25 bytes, A000070

    Tr@PartitionsP@Range@#+1&
    

    Next sequence

    LegionMammal978

    Posted 2017-07-21T15:00:01.030

    Reputation: 15 731

    The perfect sequence to use Mathematica for. – Leaky Nun – 2017-07-21T15:52:03.937

    1A000025 is an incredibly difficult one. You should add a byte to get A000026 instead. :P – MD XF – 2017-07-21T16:29:52.287

    12

    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)
    

    Peter Taylor

    Posted 2017-07-21T15:00:01.030

    Reputation: 41 901

    1 minute and 33 seconds ahead of me... while I was typing the explanation – Leaky Nun – 2017-07-21T19:05:47.637

    12

    206. Proton, 3275 bytes, A000109

    # This took me quite a while to write; if it's wrong, please tell me and I'll try to fix it without changing the byte count..
    
    permutations = x => {
    	if len(x) == 0 return [ ]
    	if len(x) == 1 return [x]
    	result = []
    	for index : range(len(x)) {
    		for permutation : permutations(x[to index] + x[index + 1 to]) {
    			result.append([x[index]] + permutation)
    		}
    	}
    	return result
    }
    
    adjacency = cycles => {
    	cycles = cycles[to]
    	size = cycles.pop()
    	matrix = [[0] * size for i : range(size)]
    	for cycle : cycles {
    		i, j, k = cycle[0], cycle[1], cycle[2]
    		matrix[i][j] = matrix[i][k] = matrix[j][i] = matrix[j][k] = matrix[k][i] = matrix[k][j] = 1
    	}
    	return matrix
    }
    
    transform = a => [[a[j][i] for j : range(len(a[i]))] for i : range(len(a))]
    
    isomorphic = (a, b) => {
    	return any(sorted(b) == sorted(transform(A)) for A : permutations(transform(a)))
    }
    
    intersection = (a, b) => [x for x : a if x in b]
    
    union = (a, b) => [x for x : a if x not in b] + list(b)
    
    validate = graph => {
    	matrix = adjacency(graph)
    	rowsums = map(sum, matrix)
    	r = 0
    	for s : rowsums if s + 1 < graph[-1] r++
    	return 2 || r
    }
    
    graphs = nodes => {
    	if nodes <= 2 return []
    	if nodes == 3 return [[(0, 1, 2), 3]]
    	result = []
    	existing = []
    	for graph : graphs(nodes - 1) {
    		graph = graph[to]
    		next = graph.pop()
    		for index : range(len(graph)) {
    			g = graph[to]
    			cycle = g.pop(index)
    			n = g + [(cycle[0], cycle[1], next), (cycle[1], cycle[2], next), (cycle[2], cycle[0], next), next + 1]
    			N = sorted(adjacency(n))
    			if N not in existing {
    				existing += [sorted(transform(a)) for a : permutations(transform(adjacency(n)))]
    				result.append(n)
    			}
    			for secondary : index .. len(graph) - 1 {
    				g = graph[to]
    				c1 = g.pop(index)
    				c2 = g.pop(secondary)
    				q = union(c1, c2)
    				g = [k for k : g if len(intersection(k, intersection(c1, c2))) <= 1]
    				if len(intersection(c1, c2)) == 2 {
    					for i : range(3) {
    						for j : i + 1 .. 4 {
    							if len(intersection(q[i, j], intersection(c1, c2))) <= 1 {
    								g.append((q[i], q[j], next))
    							}
    						}
    					}
    				}
    				g.append(next + 1)
    				N = sorted(adjacency(g))
    				if N not in existing {
    					existing += [sorted(transform(a)) for a : permutations(transform(adjacency(g)))]
    					result.append(g)
    				}
    				for tertiary : secondary .. len(graph) - 2 {
    					g = graph[to]
    					c1 = g.pop(index)
    					c2 = g.pop(secondary)
    					c3 = g.pop(tertiary)
    					q = union(union(c1, c2), c3)
    					g = [k for k : g if len(intersection(k, intersection(c1, c2))) <= 1 and len(intersection(k, intersection(c2, c3))) <= 1]
    					if len(q) == 5 and len(intersection((q1 = intersection(c1, c2)), (q2 = intersection(c2, c3)))) <= 1 and len(q1) == 2 and len(q2) == 2 {
    						for i : range(4) {
    							for j : i + 1 .. 5 {
    								if len(intersection(q[i, j], q1)) <= 1 and len(intersection(q[i, j], q2)) <= 1 {
    									g.append((q[i], q[j], next))
    								}
    							}
    						}
    						g.append(next + 1)
    						N = sorted(adjacency(g))
    						if N not in existing {
    							existing += [sorted(transform(a)) for a : permutations(transform(adjacency(g)))]
    							result.append(g)
    						}
    					}
    				}
    			}
    		}
    	}
    	return [k for k : result if max(sum(k[to -1], tuple([]))) + 1 == k[-1] and validate(k)]
    }
    
    x = graphs(int(input()) + 3)
    print(len(x))
    

    Try it online!

    Next Sequence

    HyperNeutrino

    Posted 2017-07-21T15:00:01.030

    Reputation: 26 575

    Wait, you actually did it? If you don't write a paper with these freaking programs and go talk to some professor, you're passing up on something cool :P – Stephen – 2017-10-10T02:54:06.653

    @Stephen Currently bugfixing lol – HyperNeutrino – 2017-10-10T02:58:04.553

    Is this the approach of splitting triangles, squares, and pentagons as per plantri? Looks like it might be, but some of the syntax is unfamiliar. – Peter Taylor – 2017-10-10T06:50:02.747

    1@PeterTaylor Assuming I understand the approach you're describing, yes, it looks for triangles and places a vertex adjacent to all 3 vertices, or two adjacent cycles and deletes the common edge and places a vertex adjacent to all 4, same for 3 triangles on a pentagon. I think that's one you're describing. – HyperNeutrino – 2017-10-10T12:01:06.247

    The generation looks like what is suggested by Bowen and Fisk in "Generation of triangulations of the sphere", but since you start with a single triangle you seem to miss one face? – Christian Sievers – 2017-10-10T14:37:46.990

    @ChristianSievers I don't think so? I mean the result for 3, 4, 5, 6 are all correct lol – HyperNeutrino – 2017-10-10T14:51:08.010

    Maybe it doesn't matter, maybe your code does something I didn't see. Are your graphs supposed to be triangulations of the sphere? Where did you get your ideas? As for correct results, the paper also implies that (at least if you have a sphere with all the faces) you don't need the splitting of pentagons before n=12. – Christian Sievers – 2017-10-10T15:03:44.430

    1

    @ChristianSievers https://math.stackexchange.com/a/2463430/457091

    – HyperNeutrino – 2017-10-10T15:06:55.083

    So you intended the graphs to be planar, and the same generation seems to work. Then everything seems fine! – Christian Sievers – 2017-10-10T15:27:15.707

    I tried rewriting this in Python, I cross-checked it like 10 times now. I couldn't find a bug, but the result for input 5 (n = 8) is 44, instead of the 14 expected. I left the Proton program running overnight, but it didn't finish. Using itertools' permutations and set union and intersection should speed it up a lot, but there seems to be a bug in the Proton interpreter. TL;DR: This answer may need corrections... – NieDzejkob – 2017-12-04T08:27:18.710

    @NieDzejkob Hm strange. I may need to just brute-force this then because I don't think optimizations will help me much anymore (or be correct for that matter :P). I'll try to fix it before most people notice :P – HyperNeutrino – 2017-12-04T13:19:17.530

    @HyperNeutrino using a builtin function that's more than 20 times faster must help. The only problem is the generator -> list conversion bug in Proton. – NieDzejkob – 2017-12-04T14:03:55.857

    @NieDzejkob I'll actually probably see if I can fix Proton first before retrying this. I'll probably switch to using the builtin if possible. – HyperNeutrino – 2017-12-04T14:25:41.773

    FYI, I have a Python program (modify from yours) that can calculate exactly terms up to 14. (that is, 6 first terms 1, 1, 1, 2, 5, 14, others take too much time for me) --- If you use Py(th)on for this answer instead, probably others can use Proton in next answers? --- However, because this is your answer, you would probably prefer to work it out yourself. – user202729 – 2017-12-11T13:42:27.593

    12

    308. ENIAC (simulator), 3025 bytes, A006060

    Pseudocode:

    repeat{
        M←input
        N←-M
        A←1
        B←253
        while(N<0){
            C←60
            C←C-A
            repeat(194){
                C←C+B
            }
            A←B
            B←C
            N←N+1
        }
        output←A
    }
    

    No online simulator, execution result: Card reader input Punch card output

    Registers and constants:

    A: 1-2
    B: 3-4
    C: 5-6
    M: 7
    N: 8
    
    input: const. A
    253: const. J
    60: const. K
    194: Master programmer decade limit 1B
    

    Program signal flow and data flow: Program signal flow and data flow chart

    Full "code" on pastebin or in HTML comments in the markup of this answer, to prevent linkrot and a quite long answer to scroll through at the same time. This is fun!

    Next sequence

    leo3065

    Posted 2017-07-21T15:00:01.030

    Reputation: 161

    Could you add a link to the next sequence please – Zacharý – 2018-01-08T16:52:39.707

    @Zacharý The link is in the post. I'll move it to the end of the post so it's easier to find. – leo3065 – 2018-01-08T17:02:31.383

    11

    67. LOLCODE, 837 bytes, A000043

    HAI 1.2
      CAN HAS STDIO?
    
      I HAS A CONT ITZ 0
      I HAS A ITRZ ITZ 1
      I HAS A NUMBAH
      GIMMEH NUMBAH
      NUMBAH R SUM OF NUMBAH AN 1
    
      IM IN YR GF
        ITRZ R SUM OF ITRZ AN 1
    
        I HAS A PROD ITZ 1
        IM IN YR MOM UPPIN YR ASS WILE DIFFRINT ITRZ AN SMALLR OF ITRZ AN ASS
          PROD R PRODUKT OF PROD AN 2
        IM OUTTA YR MOM
        PROD R DIFF OF PROD AN 1
    
        I HAS A PRAIME ITZ WIN
        I HAS A VAR ITZ 1
        IM IN YR MOM
          VAR R SUM OF VAR AN 1
          BOTH SAEM VAR AN PROD, O RLY?
            YA RLY, GTFO
          OIC
          BOTH SAEM 0 AN MOD OF PROD AN VAR, O RLY?
            YA RLY
              PRAIME R FAIL
              GTFO
          OIC
        IM OUTTA YR MOM
    
        BOTH SAEM PRAIME AN WIN, O RLY?
          YA RLY, CONT R SUM OF CONT AN 1
        OIC
    
        BOTH SAEM NUMBAH AN CONT, O RLY?
          YA RLY, GTFO
        OIC
      IM OUTTA YR GF
    
      VISIBLE ITRZ
    KTHXBYE
    

    My capslock key is bound to escape, so I wrote this entire thing while holding shift ..

    Try it online!

    Next sequence

    BlackCap

    Posted 2017-07-21T15:00:01.030

    Reputation: 3 576

    +1 for using PRAIME – Leaky Nun – 2017-07-23T09:07:03.713

    3You're a programmer, you could have written this and then run it through a Python script that upper'd it -.- – Stephen – 2017-07-23T12:25:09.747

    5@StepHen Or simply gggUG in vim where I wrote it, but I am not that clever – BlackCap – 2017-07-23T12:36:54.807

    10

    10. Magma, 65 bytes, A000019

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

    Try it here

    lol builtin

    Next sequence

    HyperNeutrino

    Posted 2017-07-21T15:00:01.030

    Reputation: 26 575

    @ETHproductions :) no problem, thank the OEIS page though cuz it has the exact builtin there lol – HyperNeutrino – 2017-07-21T17:20:21.037

    4;_; I solved A000064 and you changed it. Downvoted. – Leaky Nun – 2017-07-21T17:26:35.200

    My gosh, so many partition sequences – ETHproductions – 2017-07-21T17:27:56.277

    I accidentally solved A007317 while trying to do this in Python (TIO) :P

    – ETHproductions – 2017-07-21T17:36:22.187

    Re-upvoted! \o/ – Leaky Nun – 2017-07-21T17:38:27.427

    @LeakyNun \o/ thanks! anyway, you'll be able to answer this way so yay! \o/ – HyperNeutrino – 2017-07-21T17:38:56.430

    9

    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.

    Lynn

    Posted 2017-07-21T15:00:01.030

    Reputation: 55 648

    9

    121. Pip, 525 bytes, A000022

    n:(a+1)//2
    t:[[0]RL(3*a+3)PE1]
    Fh,n{
      m:([0]RL(3*a+3))
      Fi,(a+1){
        Fj,(a+1){
          Fk,(a+1)m@(i+j+k)+:(t@h@i)*(t@h@j)*(t@h@k)
          m@(i+2*j)+:3*(t@h@i)*(t@h@j)
        }
        m@(3*i)+:2*(t@h@i)
      }
      t:(tAE(m//6PE1))
    }
    k:t@n
    o:0
    Fh,aFi,aFj,aI(h+i+j<a)o+:(k@h)*(k@i)*(k@j)*k@(a-1-h-i-j)
    Fh,((a+1)//2){
      Fi,aI(2*h+i<a){o+:6*(k@h)*(k@i)*(k@(a-1-2*h-i))}
      I(a%2=1)o+:3*(k@h)*(k@((a-1-2*h)//2))
    }
    Fh,((a+2)//3)o+:8*(k@h)*(k@(a-1-3*h))
    I(a%4=1)o+:6*k@(a//4)
    o//:24
    Ia(o+:t@n@a)
    Fh,nFj,(a+1)o-:(t@(h+1)@j-t@h@j)*(t@(h+1)@(a-j))
    o
    

    Online demo

    Next sequence

    Fun fact: when the challenge was first posted, I drew up a list of small nasty sequence numbers that I wanted to aim for with CJam, and A000022 was at the top of the list.

    This implements the generating function described in E. M. Rains and N. J. A. Sloane, On Cayley's Enumeration of Alkanes (or 4-Valent Trees), Journal of Integer Sequences, Vol. 2 (1999), taking the sum for Ck to as many terms as a necessary for the nth coefficient to be fixed and then telescoping three quarters of the sum. In particular, telescoping the first half means that the cycle index of S4 only has to be applied to one of the Th rather than to all of them.

    The code breaks down as

    ; Calculate the relevant T_h
    t:[[0]RL(3*a+3)PE1]
    Fh,n{
      m:([0]RL(3*a+3))
      Fi,(a+1){
        Fj,(a+1){
          Fk,(a+1)m@(i+j+k)+:(t@h@i)*(t@h@j)*(t@h@k)
          m@(i+2*j)+:3*(t@h@i)*(t@h@j)
        }
        m@(3*i)+:2*(t@h@i)
      }
      t:(tAE(m//6PE1))
    }
    
    ; Calculate the cycle index of S_4 applied to the last one
    k:t@n
    o:0
    Fh,aFi,aFj,aI(h+i+j<a)o+:(k@h)*(k@i)*(k@j)*k@(a-1-h-i-j)
    Fh,((a+1)//2){
      Fi,aI(2*h+i<a){o+:6*(k@h)*(k@i)*(k@(a-1-2*h-i))}
      I(a%2=1)o+:3*(k@h)*(k@((a-1-2*h)//2))
    }
    Fh,((a+2)//3)o+:8*(k@h)*(k@(a-1-3*h))
    I(a%4=1)o+:6*k@(a//4)
    o//:24
    
    ; Handle the remaining convolution,
    ; pulling out the special case which involves T_{-2}
    Ia(o+:t@n@a)
    Fh,nFj,(a+1)o-:(t@(h+1)@j-t@h@j)*(t@(h+1)@(a-j))
    

    Note that this is my first ever Pip program, so is probably not very idiomatic.

    Peter Taylor

    Posted 2017-07-21T15:00:01.030

    Reputation: 41 901

    Comments are not for extended discussion; this conversation has been moved to chat.

    – Dennis – 2017-08-31T12:28:24.363

    9

    156. C# (Mono), 2466 bytes, A000083

    Note: the score is 2439 bytes for the code and 27 for the compiler flag -reference:System.Numerics.

    using Num = System.Numerics.BigInteger;
    namespace PPCG
    {
        class A000083
        {
            static void Main(string[] a)
            {
                int N = int.Parse(a[0]) + 1;
    
                var phi = new int[N + 1];
                for (int i = 1; i <= N; i++)
                    phi[i] = 1;
                for (int p = 2; p <= N; p++)
                {
                    if (phi[p] > 1) continue;
                    for (int i = p; i <= N; i += p)
                        phi[i] *= p - 1;
                    int pa = p * p;
                    while (pa <= N)
                    {
                        for (int i = pa; i <= N; i += pa)
                            phi[i] *= p;
                        pa *= p;
                    }
                }
    
                var aik = new Num[N + 1, N + 1];
                var a035350 = new Num[N + 1];
                var a035349 = new Num[N + 1];
                aik[0, 0] = aik[1, 1] = a035350[0] = a035350[1] = a035349[0] = a035349[1] = 1;
                for (int n = 2; n <= N; n++)
                {
                    // A000237 = EULER(A035350)
                    Num nbn = 0;
                    for (int k = 1; k < n; k++)
                        for (int d = 1; d <= k; d++)
                            if (k % d == 0) nbn += d * a035350[d] * aik[1, n - k];
                    aik[1, n] = nbn / (n - 1);
    
                    // Powers of A000237 are used a lot
                    for (int k = 2; k <= N; k++)
                        for (int i = 0; i <= n; i++)
                            aik[k, n] += aik[k - 1, i] * aik[1, n - i];
    
                    // A035350 = BIK(A000237)
                    Num bn = 0;
                    for (int k = 1; k <= n; k++)
                    {
                        bn += aik[k, n];
                        if (k % 2 == 1)
                            for (int i = n & 1; i <= n; i += 2)
                                bn += aik[1, i] * aik[k / 2, (n - i) / 2];
                        else if (n % 2 == 0)
                            bn += aik[k / 2, n / 2];
                    }
                    a035350[n] = bn / 2;
    
                    // A035349 = DIK(A000237)
                    Num dn = 0;
                    for (int k = 1; k <= n; k++)
                    {
                        // DIK_k is Polyà enumeration with the cyclic group D_k
                        // The cycle index for D_k has two parts: C_k and what Bower calls CPAL_k
                        // C_k
                        Num cikk = 0;
                        for (int d = 1; d <= k; d++)
                            if (k % d == 0 && n % d == 0)
                                cikk += phi[d] * aik[k / d, n / d];
                        dn += cikk / k;
    
                        // CPAL_k
                        if (k % 2 == 1)
                            for (int i = 0; i <= n; i += 2)
                                dn += aik[1, n - i] * aik[k / 2, i / 2];
                        else
                        {
                            Num cpalk = 0;
                            for (int i = 0; i <= n; i += 2)
                                cpalk += aik[2, n - i] * aik[k / 2 - 1, i / 2];
                            if (n % 2 == 0)
                                cpalk += aik[k / 2, n / 2];
                            dn += cpalk / 2;
                        }
                    }
                    a035349[n] = dn / 2;
                }
    
                // A000083 = A000237 + A035350 - A000237 * A035349
                var a000083 = new Num[N + 1];
                for (int i = 0; i <= N; i++)
                {
                    a000083[i] = aik[1, i] + a035349[i];
                    for (int j = 0; j <= i; j++) a000083[i] -= aik[1, j] * a035350[i - j];
                }
    
                System.Console.WriteLine(a000083[N - 1]);
            }
        }
    }
    

    Online demo. This is a full program which takes input from the command line.

    Next sequence

    Dissection

    I follow Bowen's comment in OEIS that the generating function A000083(x) = A000237(x) + A035349(x) - A000237(x) * A035350(x) where the component generating functions are related by transforms as

    • A000237(x) = x EULER(A035350(x))
    • A035350(x) = BIK(A000237(x))
    • A035349(x) = DIK(A000237(x))

    I use the definitions of BIK and DIK from https://oeis.org/transforms2.html but the formulae seem to have a number of typos. I corrected LPAL without much difficulty, and independently derived a formula for DIK based on applying Pólya enumeration to the cycle index of the dihedral group. Between #121 and #156 I'm learning a lot about Pólya enumeration. I have submitted some errata, which may prove useful to other people if these transforms come up again in the chain.

    Peter Taylor

    Posted 2017-07-21T15:00:01.030

    Reputation: 41 901

    8

    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)

    ETHproductions

    Posted 2017-07-21T15:00:01.030

    Reputation: 47 880

    "(should be an easy one :P)" it was – Erik the Outgolfer – 2017-07-21T15:24:08.460

    8

    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

    MD XF

    Posted 2017-07-21T15:00:01.030

    Reputation: 11 605

    Is that valid input? – Leaky Nun – 2017-07-21T17:35:41.190

    Didya have to get 64 bytes? :P – totallyhuman – 2017-07-21T17:40:56.947

    @totallyhuman yes: ;_; I solved A000064 and you changed it. Downvoted. – Stephen – 2017-07-21T17:41:09.147

    @totallyhuman compromises lol. see chat – HyperNeutrino – 2017-07-21T17:41:23.737

    Dang – Mr. Xcoder – 2017-07-21T17:42:12.540

    @Mr.Xcoder 127 wouldn't be interesting... – Leaky Nun – 2017-07-21T17:45:43.493

    8

    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!

    Brian J

    Posted 2017-07-21T15:00:01.030

    Reputation: 653

    8

    91. Python 2 (PyPy), 1733 bytes, A000066

    import itertools
    
    girth = int(input()) + 3
    
    v = 4
    
    r = range
    
    def p(v):
    	a = [0 for i in r(v)]
    	k = int((v * 2) ** .5)
    	a[k - 1] = a[k - 2] = a[k - 3] = 1
    	j = len(a) - 1
    	for i in r(1, 3):
    		a[j] = 1
    		j -= i
    	yield [x for x in a]
    	while not all(a):
    		for index in r(len(a) - 1, -1, -1):
    			a[index] ^= 1
    			if a[index]: break
    		yield [x for x in a]
    
    def wrap_(p, v):
    	m = [[0 for j in r(v)] for i in r(v)]
    	k = 0
    	for i in r(0, v - 1):
    		for j in r(i + 1, v):
    			m[i][j] = m[j][i] = p[k]
    			k += 1
    	return m
    
    def completes_cycle(edgelist):
    	if not edgelist or not edgelist[1:]: return False
    	start = edgelist[0]
    	edge = edgelist[0]
    	e = [x for x in edgelist]
    	edgelist = edgelist[1:]
    	while edgelist:
    		_edges = [_edge for _edge in edgelist if _edge[0] in edge or _edge[1] in edge]
    		if _edges:
    			edgelist.remove(_edges[0])
    			if _edges[0][1] in edge: _edges[0] = (_edges[0][1], _edges[0][0])
    			edge = _edges[0]
    		else:
    			return False
    	flat = sum(e, ())
    	for i in flat:
    		if flat.count(i) != 2: return False
    	return edge[1] in start
    
    def powerset(a):
    	return sum([list(itertools.combinations(a, t)) for t in r(len(a))], [])
    
    while True:
    	ps = (v * (v - 1)) // 2
    	skip = False
    	for Q in p(ps):
    		m = wrap_(Q, v)
    		output = [row + [0] for row in m]
    		output.append([0 for i in r(len(m[0]))])
    		for i in r(len(m)):
    			output[i][-1] = sum(m[i])
    			output[-1][i] = sum(row[i] for row in m)
    		if all(map(lambda x: x == 3, map(sum, m))):
    			edges = []
    			for i in r(v):
    				for j in r(i, v):
    					if m[i][j]: edges.append((i, j))
    			for edgegroup in powerset(edges):
    				if completes_cycle(list(edgegroup)):
    					if len(edgegroup) == girth:
    						print(v)
    						exit(0)
    					else:
    						skip = True
    						break
    		if skip: break
    	v += 1
    

    Try it online!

    I hope using Python 2 PyPy counts as another major version. If someone could get me a Python 0 interpreter, I could use that too, but I hope this is valid.

    This starts at 1 vertex and works up, creating the adjacency matrix representation of every possible undirected graph with that many vertices. If it is trivalent, then it will look through the powerset of the edges, which will be sorted by length. If the first cycle it finds is too short, then it will move on. If the first cycle it finds matches the input (offset by 3) then it will output the correct vertex count and terminate.

    Next Sequence <-- have an easy one as a break from all this math nonsense :D

    EDIT: I added some optimizations to make it a bit faster (still can't compute the third term within TIO's 60 second limit though) without changing the bytecount.

    HyperNeutrino

    Posted 2017-07-21T15:00:01.030

    Reputation: 26 575

    ... and I was seriously thinking the chain would end with answer 90 – pppery – 2017-07-31T00:04:35.870

    1@ppperry :) I like doing hard challenges because most people can't even make a solution so I don't have to worry about getting outgolfed :) (e.g. the carbon chain namer problem) – HyperNeutrino – 2017-07-31T00:25:43.853

    Unless someone takes your solution and converts it into a terser language – pppery – 2017-07-31T00:26:28.133

    @ppperry that too o_O :P – HyperNeutrino – 2017-07-31T00:26:52.460

    1@HyperNeutrino Congrats on solving that! I was worried I had broken the chain, and was considering padding the byte count to point to a different sequence. Good job! – Scott Milner – 2017-07-31T22:27:10.027

    @ScottMilner Glad you didn't :) I would have rolled it back since we really don't like people doing that :P – HyperNeutrino – 2017-08-01T00:28:59.043

    Come on, this deserves way more upvotes than it has. – NieDzejkob – 2017-09-05T05:02:10.343

    8

    232. Funky, 326 330 332 bytes, A000938

    function gcd (a, b) {
        while (b != 0) {
            c = a % b;
            a = b;
            b = c;
        };
        return a;
    }
    
    function A000938 (n) {
        n = n + 2;
        ans = 0;
        for (m = 2; m <= n; ++m) {
            for (k = 2; k <= n; ++k) {
                ans = ans + (((n - k) + 1) * ((n - m) + 1) * gcd(k - 1, m - 1));
            }
        }
        ans = (2 * ans) - (
            (n*n) *
            ((n*n)-1) / 6
        );
        return ans;
    }
    

    Try it online!

    Polyglot with Javascript. Try it online!

    Next sequence.


    Use the formula on the OEIS page for O(n^2 log n) complexity, instead of the naive O(n^6).

    Quick explanation:

    • This code use the formula a[n_] := 2*Sum[(n - k + 1)*(n - m + 1)*GCD[k - 1, m - 1], {m, 2, n}, {k, 2, n}] - n^2*((n^2 - 1)/6) described in the Mathematica code section.
    • Formula proof:

      • The formula is equivalent to this.

      • Let the size of the bounding box of three points be m * k. Consider 2 cases:

        • k != 0 and m != 0: There are 2 ways to choose the orientation of the three points (\ or /), gcd(k-1, m-1)-1 ways to choose the point lies between the other 2 points, and (n - k) × (n - m) ways to choose the position of the bounding box.
        • k == 0 or m == 0: There are 2 ways to choose the orientation (| or -), n ways to choose the row/column the points lies on, and Binomial[n, 3] == (n*(n-1)*(n-2)) / 6 ways to choose the points on that row/column.

    Some polyglot notes:

    • Funky doesn't really have keyword return. However, as ATaco explained, [Funky] thinks return is a variable. So it's parsing that expression, which conveniently does nothing, then parses the next expression. And this is used as an output.
    • Javascript use ^ as bitwise xor, unlike Funky which use ^ as exponentiation. So n*n have to be used instead of n^2 to ensure Javascript compatibility.
    • In Funky, all operator (+, -, *, etc.) have equal precedence and right-associative, so expressions need to be parenthesized properly.

    user202729

    Posted 2017-07-21T15:00:01.030

    Reputation: 14 620

    1+1 was not expecting a polyglot. – ATaco – 2017-10-21T03:11:53.237

    There's no Pentagony, but Hexagony fits well. – NieDzejkob – 2017-10-21T05:24:21.843

    This bytecount was used already... link

    – NieDzejkob – 2017-12-05T14:22:10.863

    So, to fix the bytecount problem, could you please pad this answer to 330 bytes? I'll handle the rest. – NieDzejkob – 2017-12-05T17:41:31.077

    [Answer padded to 332 bytes because of bytecount conflicting issues, see this chat message]

    – user202729 – 2017-12-08T00:50:51.870

    8

    281. Java 5, 11628 bytes, A000947

    // package oeis_challenge;
    
    import java.util.*;
    import java.lang.*;
    
    class Main {
    
    //  static void assert(boolean cond) {
    //      if (!cond)
    //          throw new Error("Assertion failed!");
    //  }
    
        /* Use the formula a(n) = A000063(n + 2) - A000936(n).
        It's unfair that I use the formula of "number of free polyenoid with n
        nodes and symmetry point group C_{2v}" (formula listed in A000063)
        without understanding why it's true...
        */
    
        static int catalan(int x) {
            int ans = 1;
            for (int i = 1; i <= x; ++i)
                ans = ans * (2*x+1-i) / i;
            return ans / -~x;
        }
    
        static int A63(int n) {
            int ans = catalan(n/2 - 1);
            if (n%4 == 0) ans -= catalan(n/4 - 1);
            if (n%6 == 0) ans -= catalan(n/6 - 1);
            return ans;
        }
    
        static class Point implements Comparable<Point> {
            final int x, y;
            Point(int _x, int _y) {
                x = _x; y = _y;
            }
    
            /// @return true if this is a point, false otherwise (this is a vector)
            public boolean isPoint() {
                return (x + y) % 3 != 0;
            }
    
            /// Translate this point by a vector.
            public Point add(Point p) {
                assert(this.isPoint() && ! p.isPoint());
                return new Point(x + p.x, y + p.y);
            }
    
            /// Reflect this point along x-axis.
            public Point reflectX() {
                return new Point(x - y, -y);
            }
    
            /// Rotate this point 60 degrees counter-clockwise.
            public Point rot60() {
                return new Point(x - y, x);
            }
    
            @Override
            public boolean equals(Object o) {
                if (!(o instanceof Point)) return false;
                Point p = (Point) o;
                return x == p.x && y == p.y;
            }
    
            @Override
            public int hashCode() {
                return 21521 * (3491 + x) + y;
            }
    
            public String toString() {
                // return String.format("(%d, %d)", x, y);
                return String.format("setxy %d %d", x * 50 - y * 25, y * 40);
            }
    
            public int compareTo(Point p) {
                int a = Integer.valueOf(x).compareTo(p.x);
                if (a != 0) return a;
                return Integer.valueOf(y).compareTo(p.y);
            }
    
            /// Helper class.
            static interface Predicate {
                abstract boolean test(Point p);
            }
    
            static abstract class UnaryFunction {
                abstract Point apply(Point p);
            }
    
        }
    
        static class Edge implements Comparable<Edge> {
            final Point a, b; // guarantee a < b
            Edge(Point x, Point y) {
                assert x != y;
                if (x.compareTo(y) > 0) { // y < x
                    a = y; b = x;
                } else {
                    a = x; b = y;
                }
            }
    
            public int compareTo(Edge e) {
                int x = a.compareTo(e.a);
                if (x != 0) return x;
                return b.compareTo(e.b);
            }
        }
    
        /// A graph consists of multiple {@code Point}s.
        static class Graph {
            private HashMap<Point, Point> points;
    
            public Graph() {
                points = new HashMap<Point, Point>();
            }
    
            public Graph(Graph g) {
                points = new HashMap<Point, Point>(g.points);
            }
    
            public void add(Point p, Point root) {
                assert(p.isPoint());
                assert(root.isPoint());
                assert(p == root || points.containsKey(root));
                points.put(p, root);
            }
    
            public Graph map(Point.UnaryFunction fn) {
                Graph result = new Graph();
                for (Map.Entry<Point, Point> pq : points.entrySet()) {
                    Point p = pq.getKey(), q = pq.getValue();
                    assert(p.isPoint()) : p;
                    assert(q.isPoint()) : q;
                    p = fn.apply(p); assert(p.isPoint()) : p;
                    q = fn.apply(q); assert(q.isPoint()) : q;
                    result.points.put(p, q);
                }
                return result;
            }
    
            public Graph reflectX() {
                return this.map(new Point.UnaryFunction() {
                    public Point apply(Point p) {
                        return p.reflectX();
                    }
                });
            }
    
            public Graph rot60() {
                return this.map(new Point.UnaryFunction() {
                    public Point apply(Point p) {
                        return p.rot60();
                    }
                });
            }
    
            @Override
            public boolean equals(Object o) {
                if (o == null) return false;
                if (o.getClass() != getClass()) return false;
                Graph g = (Graph) o;
                return points.equals(g.points);
            }
    
            @Override
            public int hashCode() {
                return points.hashCode();
            }
    
            Graph[] expand(Point.Predicate fn) {
                List<Graph> result = new ArrayList<Graph>();
    
                for (Point p : points.keySet()) {
                    int[] deltaX = new int[] { -1, 0, 1, 1,  0, -1};
                    int[] deltaY = new int[] {  0, 1, 1, 0, -1, -1};
                    for (int i = 6; i --> 0;) {
                        Point p1 = new Point(p.x + deltaX[i], p.y + deltaY[i]);
                        if (points.containsKey(p1) || !fn.test(p1)
                            || !p1.isPoint()) continue;
    
                        Graph g = new Graph(this);
                        g.add(p1, p);
                        result.add(g);
                    }
                }
    
                return result.toArray(new Graph[0]);
            }
    
            public static Graph[] expand(Graph[] graphs, Point.Predicate fn) {
                Set<Graph> result = new HashSet<Graph>();
    
                for (Graph g0 : graphs) {
                    Graph[] g = g0.expand(fn);
                    for (Graph g1 : g) {
                        if (result.contains(g1)) continue;
                        result.add(g1);
                    }
                }
    
                return result.toArray(new Graph[0]);
            }
    
            private Edge[] edges() {
                List<Edge> result = new ArrayList<Edge>();
                for (Map.Entry<Point, Point> pq : points.entrySet()) {
                    Point p = pq.getKey(), q = pq.getValue();
                    if (p.equals(q)) continue;
                    result.add(new Edge(p, q));
                }
                return result.toArray(new Edge[0]);
            }
    
            /**
             * Check if two graphs are isomorphic... under translation.
             * @return {@code true} if {@code this} is isomorphic
             * under translation, {@code false} otherwise.
             */
            public boolean isomorphic(Graph g) {
                if (points.size() != g.points.size()) return false;
                Edge[] a = this.edges();
                Edge[] b = g.edges();
                Arrays.sort(a);
                Arrays.sort(b);
    
                // for (Edge e : b)
                    // System.err.println(e.a + " - " + e.b);
                // System.err.println("------- >><< ");
    
                assert (a.length > 0);
                assert (a.length == b.length);
                int a_bx = a[0].a.x - b[0].a.x, a_by = a[0].a.y - b[0].a.y;
                for (int i = 0; i < a.length; ++i) {
                    if (a_bx != a[i].a.x - b[i].a.x || 
                        a_by != a[i].a.y - b[i].a.y) return false;
                    if (a_bx != a[i].b.x - b[i].b.x || 
                        a_by != a[i].b.y - b[i].b.y) return false;
                }
    
                return true;
            }
    
            // C_{2v}.
            public boolean correctSymmetry() {
    
                Graph[] graphs = new Graph[6];
                graphs[0] = this.reflectX();
                for (int i = 1; i < 6; ++i) graphs[i] = graphs[i-1].rot60();
                assert(graphs[5].rot60().isomorphic(graphs[0]));
                int count = 0;
                for (Graph g : graphs) {
                    if (this.isomorphic(g)) ++count;
                    // if (count >= 2) {
                        // return false;
                    // }
                }
                // if (count > 1) System.err.format("too much: %d%n", count);
                assert(count > 0);
                return count == 1; // which is, basically, true
            }
    
            public void reflectSelfType2() {
                Graph g = this.map(new Point.UnaryFunction() {
                    public Point apply(Point p) {
                        return new Point(p.y - p.x, p.y);
                    }
                });
    
                Point p = new Point(1, 1);
                assert (p.equals(points.get(p)));
    
                points.putAll(g.points);
    
                assert (p.equals(points.get(p)));
                Point q = new Point(0, 1);
                assert (q.equals(points.get(q)));
                points.put(p, q);
            }
    
            public void reflectSelfX() {
                Graph g = this.reflectX();
                points.putAll(g.points); // duplicates doesn't matter
            }
    
        }
    
        static int A936(int n) {
            // if (true) return (new int[]{0, 0, 0, 1, 1, 2, 4, 4, 12, 10, 29, 27, 88, 76, 247, 217, 722, 638, 2134, 1901, 6413})[n];
    
            // some unreachable codes here for testing.
            int ans = 0;
    
            if (n % 2 == 0) { // reflection type 2. (through line 2x == y)
                Graph[] graphs = new Graph[1];
                graphs[0] = new Graph();
    
                Point p = new Point(1, 1);
                graphs[0].add(p, p);
    
                for (int i = n / 2 - 1; i --> 0;)
                    graphs = Graph.expand(graphs, new Point.Predicate() {
                        public boolean test(Point p) {
                            return 2*p.x > p.y;
                        }
                    });
    
                int count = 0;
                for (Graph g : graphs) {
                    g.reflectSelfType2();
                    if (g.correctSymmetry()) {
                        ++count;
    
                        // for (Edge e : g.edges())
                            // System.err.println(e.a + " - " + e.b);
                        // System.err.println("------*");
    
                        }
                    // else System.err.println("Failed");
                }
    
                assert (count%2 == 0);
    
                // System.err.println("A936(" + n + ") count = " + count + " -> " + (count/2));
    
                ans += count / 2;
    
            }
    
            // Reflection type 1. (reflectX)
    
            Graph[] graphs = new Graph[1];
            graphs[0] = new Graph();
    
            Point p = new Point(1, 0);
            graphs[0].add(p, p);
    
            if (n % 2 == 0) graphs[0].add(new Point(2, 0), p);
    
            for (int i = (n-1) / 2; i --> 0;)
                graphs = Graph.expand(graphs, new Point.Predicate() {
                    public boolean test(Point p) {
                        return p.y > 0;
                    }
                });
    
            int count = 0;
            for (Graph g : graphs) {
                g.reflectSelfX();
                if (g.correctSymmetry()) {
                    ++count;
                    // for (Edge e : g.edges())
    
                        // System.err.printf(
    
                    // "pu %s pd %s\n"
                    // // "%s - %s%n"
    
                    // , e.a, e.b);
                    // System.err.println("-------/");
    
                }
                // else System.err.println("Failed");
            }
    
            if(n % 2 == 0) {
                assert(count % 2 == 0);
                count /= 2;
            }
            ans += count;
    
            // System.err.println("A936(" + n + ") = " + ans);
    
            return ans;
        }
    
        public static void main(String[] args) {
    
            // Probably
            if (! "1.5.0_22".equals(System.getProperty("java.version"))) {
                System.err.println("Warning: Java version is not 1.5.0_22");
            }
    
            // A936(6);
    
            for (int i = 0; i < 20; ++i)
                System.out.println(i + " | " + (A63(i+9) - A936(i+7)));
            //A936(i+2);
        }
    }
    

    Try it online!


    Side note:

    1. Tested locally with Java 5. (such that the warning is not printed - see TIO debug tab)
    2. Don't. Ever. Use. Java. 1. It's more verbose than Java in general.
    3. This may break the chain.
    4. The gap (7 days and 48 minutes) is no more than the gap created by this answer, which is 7 days and 1 hours 25 minutes later than the previous one.
    5. New record on large bytecount! Because I (mistakenly?) use spaces instead of tabs, the bytecount is larger than necessary. On my machine it's 9550 bytes. (at the time of writing this revision)
    6. Next sequence.
    7. The code, in its current form, only prints the first 20 terms of the sequence. However it's easy to change so that it will prints first 1000 items (by change the 20 in for (int i = 0; i < 20; ++i) to 1000)

    Yay! This can compute more terms than listed on the OEIS page! (for the first time, for a challenge I need to use Java) unless OEIS has more terms somewhere...


    Quick explanation

    Explanation of the sequence description.

    The sequence ask for the number of free nonplanar polyenoid with symmetry group C2v, where:

    • polyenoid: (mathematical model of polyene hydrocarbons) trees (or in degenerate case, single vertex) with can be embedded in hexagonal lattice.

    For example, consider the trees

          O                O           O      O       (3)
          |                 \         /        \
          |                  \       /          \
    O --- O --- O             O --- O            O --- O
          |                                             \
          |                    (2)                       \
     (1)  O                                               O
    

    The first one cannot be embedded in the hexagonal lattice, while the second one can. That particular embedding is considered different from the third tree.

    • nonplanar polyenoid: embedding of trees such that there exists two overlapping vertices.

    (2) and (3) tree above are planar. This one, however, is nonplanar:

       O---O O
      /       \
     /         \
    O           O
     \         /
      \       /
       O --- O
    

    (there are 7 vertices and 6 edges)

    • free polyenoid: Variants of one polyenoid, which can be obtained by rotation and reflection, is counted as one.

    • C2v group: The polyenoid are only counted if they have 2 perpendicular planes of reflection, and no more.

    For example, the only polyenoid with 2 vertices

    O --- O
    

    has 3 planes of reflection: The horizontal one -, the vertical one |, and the one parallel to the computer screen . That's too much.

    On the other hand, this one

    O --- O
           \
            \
             O
    

    has 2 planes of reflection: / and .


    Explanation of the method

    And now, the approach on how to actually count the number.

    First, I take the formula a(n) = A000063(n + 2) - A000936(n) (listed on the OEIS page) for granted. I didn't read the explanation in the paper.

    [TODO fix this part]

    Of course, counting planar is easier than counting nonplanar. That's what the paper does, too.

    Geometrically planar polyenoids (without overlapping vertices) are enumerated by computer programming. Thus the numbers of geometrically nonplanar polyenoids become accessible.

    So... the program counts the number of planar polyenoid, and subtract it from the total.

    Because the tree is planar anyway, it obviously has the plane of reflection. So the condition boils down to "count number of tree with an axis of reflection in its 2D representation".

    The naive way would be generate all trees with n nodes, and check for correct symmetry. However, because we only want to find the number of trees with an axis of reflection, we can just generate all possible half-tree on one half, mirror them through the axis, and then check for correct symmetry. Moreover, because the polyenoids generated are (planar) trees, it must touch the axis of reflection exactly once.

    The function public static Graph[] expand(Graph[] graphs, Point.Predicate fn) takes an array of graphs, each have n nodes, and output an array of graph, each has n+1 nodes, not equal to each other (under translation) - such that the added node must satisfy the predicate fn.

    Consider 2 possible axes of reflection: One that goes through an vertex and coincide with edges (x = 0), and one that is the perpendicular bisector of an edge (2x = y). We can take only one of them because the generated graphs are isomorphic, anyway.

    So, for the first axis x = 0, we start from the base graph consists of a single node (1, 0) (in case n is odd) or two nodes with an edge between (1, 0) - (2, 0) (in case n is even), and then expand nodes such that y > 0. That's done by the "Reflection type 1" section of the program, and then for each generated graph, reflect (mirror) itself through the X axis x = 0 (g.reflectSelfX()), and then check if it has the correct symmetry.

    However, note that if n is divisible by 2, by this way we counted each graph twice, because we also generate its mirror image by the axis 2x = y + 3.

    (note the 2 orange ones)

    Similar for the axis 2x = y, if (and only if) n is even, we start from the point (1, 1), generate graphs such that 2*x > y, and reflect each of them over the 2x = y axis (g.reflectSelfType2()), connect (1, 0) with (1, 1), and check if they have correct symmetry. Remember to divide by 2, too.

    user202729

    Posted 2017-07-21T15:00:01.030

    Reputation: 14 620

    Given that I was asleep when this (and the other one) were posted, I'll give you the benefit of the doubt and not accept an answer yet. – caird coinheringaahing – 2017-12-24T06:21:34.343

    2@cairdcoinheringaahing You were online 3 minutes before the deadline... – user202729 – 2017-12-24T06:23:02.487

    Uh oh, the next sequence can be hard-coded... (although it's infinite) if I read it correctly. The calculation itself is ---pretty--- very easy, so don't do it. – user202729 – 2017-12-24T12:39:27.560

    7

    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

    Leaky Nun

    Posted 2017-07-21T15:00:01.030

    Reputation: 45 011

    1For the love of God, I didn't check the next sequence before I posted this answer. – Leaky Nun – 2017-07-21T15:38:27.433

    Isn't an easy next sequence a strategic advantage? – BlackCap – 2017-07-21T15:39:33.163

    @BlackCap They can't answer twice in a row or less than 1 hour after they last answered. – Erik the Outgolfer – 2017-07-21T15:41:06.180

    @EriktheOutgolfer the answer before the last posted (the one who didn't break the chain) will win – BlackCap – 2017-07-21T15:41:57.853

    @BlackCap at this point that isn't going to happen – Stephen – 2017-07-21T15:42:22.510

    @StepHen You never know, you could get digits of Chaitin's constant or something of that nature – BlackCap – 2017-07-21T15:45:38.177

    7

    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.

    totallyhuman

    Posted 2017-07-21T15:00:01.030

    Reputation: 15 378

    3Wow you ninja'd by 2 seconds – Business Cat – 2017-07-21T18:13:13.710

    7

    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

    Scott Milner

    Posted 2017-07-21T15:00:01.030

    Reputation: 1 806

    Agh I knew when the site went down that it would be a mad rush when it came back up. Barely beat me. – Silvio Mayolo – 2017-07-22T00:33:10.520

    I didn't realize the site went down... – Scott Milner – 2017-07-22T00:33:34.267

    https://twitter.com/Nick_Craver/status/888553194313449472 – Silvio Mayolo – 2017-07-22T00:34:25.050

    7

    34. Prolog (SWI), 168 bytes, A000073

    tribonacci(0,0).
    tribonacci(1,0).
    tribonacci(2,1).
    tribonacci(A,B):-
    	C is A-1,
    	D is A-2,
    	E is A-3,
    	tribonacci(C,F),
    	tribonacci(D,G),
    	tribonacci(E,H),
    	B is F+G+H.
    

    Try it online!

    Next sequence

    Leaky Nun

    Posted 2017-07-21T15:00:01.030

    Reputation: 45 011

    7

    49. SageMath, 74 bytes, A000003

    lambda n: len(BinaryQF_reduced_representatives(-4*n, primitive_only=True))
    

    Try it online!

    Next sequence

    alephalpha

    Posted 2017-07-21T15:00:01.030

    Reputation: 23 988

    And I just spent an hour trying to work this sequence out using JavaScript... oh well, I'll just have to move on to the next one... – ETHproductions – 2017-07-22T15:20:55.100

    7

    76. Pygmy, 4147 bytes, A000036

    globaln: 0                                                                                           
    
    Pi:: 3.141592653589793                                                                               
    
    floor:: (number) {                                                                                   
        floatPart: number % 1                                                                            
        number >= 0 =>                                                                                   
        number - floatPart                                                                               
        number - floatPart - 1                                                                           
    }                                                                                                    
    
    fsqrt:: (number) {                                                                                   
        floor| number ^ 0.5                                                                              
    }                                                                                                    
    
    summation:: (f i imax) {                                                                             
        i > imax => 0                                                                                    
        (f| i) + summation| f, i + 1, imax                                                               
    }                                                                                                    
    
    absoluteValue:: (number) {                                                                           
        number < 0 => -number                                                                            
        number                                                                                           
    }                                                                                                    
    
    A:: (number) {                                                                                       
        globaln~: number                                                                                 
        1 + 4 * (fsqrt| number)                                                                          
           + 4 * (fsqrt| number / 2) ^ 2                                                                 
           + 8 * summation| (j){ fsqrt| globaln - j * j }, (fsqrt| number / 2) + 1, (fsqrt| number)      
    }                                                                                                    
    
    V:: (number) {                                                                  
        Pi * number                                                                      
    }                                                                                    
    
    P:: (number) {                                             
        (A| number) - (V| number)                               
    }                                                           
    
    recordMax: 0                                           
    findRecord:: (searchIndex record recordCount) {                                    
        x: absoluteValue| P| searchIndex                                               
        (x > record && recordCount = recordMax - 1) => searchIndex                     
        x > record => findRecord| searchIndex + 1, x, recordCount + 1                  
        findRecord| searchIndex + 1, record, recordCount                               
    }                                                                                  
    
    A000099:: (number) {                                                                 
        recordMax~: number                                                              
        findRecord| 1, 0, 0                                                              
    }                                                                               
    
    A000035:: (number) {                                                                       
        floor| (P| (A000099| number)) + 0.5                                         
    }                                                                               
    

    Next Sequence

    You can run the code on this page. For example, you can get the 10th number in the sequence by copying the code above and adding:

    alert| A000035| 10
    

    Peter Olson

    Posted 2017-07-21T15:00:01.030

    Reputation: 7 412

    4... the next sequence is uncomputable... – HyperNeutrino – 2017-07-24T16:14:40.103

    1@HyperNeutrino I know :P I did this on purpose – Peter Olson – 2017-07-24T16:18:21.353

    Evil... >.< But anyway, I'll just hardcode the 4 elements in the sequence. Easy enough xD OP approves of it apparently ¯\(ツ) – HyperNeutrino – 2017-07-24T16:20:14.067

    7

    184. CJam, 142 bytes, A000061

    {_,@f*\f%1\{)1$f-@+:*\}h;g}:J;
    {)_mF{~2/#}%:*:M_*/:B_4%1={_2/,f{)_2$J@@4*-*}}{_,{1&},f{1$1$J@@-*}}?1b0.5e|M3#*Mmf{2>},_&{_2#_@B\J-@*\/}/0.5+i}
    

    Online test suite. This is an anonymous block (function) with an auxiliary named block (function) to calculate the Jacobi symbol.

    Note: the formulae given in OEIS as it currently stands (revision 39) are badly transcribed from the Shanks paper. They miss an exponent and one special case and give a different special case incorrectly. I shall propose amendments.

    Also note that for the Jacobi symbol I'm using the Zolotarev-style approach I mentioned in an earlier answer of calculating the Levi-Civita symbol of a linear map. The implementation of J above is not the same as the one I previously proposed: it's the same length, but I think it's less wasteful.

    The next sequence is a nice easy one, so maybe someone can bring the lowest uncovered sequence, A000017, into play. That should make the hard-coders happy.

    Peter Taylor

    Posted 2017-07-21T15:00:01.030

    Reputation: 41 901

    minor nit: you can always make the next sequence the lowest uncovered one by adding 300,000 bytes of padding. – pppery – 2017-09-26T20:48:02.613

    7

    191. Haskell, 1824 bytes, A000725

    import Data.List (sort, group, permutations)
    import Control.Monad (replicateM)
    import qualified Data.Set as S
    import qualified Data.Map.Strict as M
    
    type V = [Bool]
    
    parts :: Int -> [[Int]]
    parts n = partsm n n
      where partsm 0 _ = [[]]
            partsm n m = [ v:p | v <- [1 .. min n m], p <- partsm (n-v) v ]
    
    fact :: Int -> Integer
    fact n = product [1 .. fromIntegral n]
    
    centralizerSize :: [Int] -> Integer
    centralizerSize cyclens =
      product [ l^m * fact m | ll <- group (sort cyclens),
                               let l = fromIntegral $ head ll,
                               let m = length ll             ]
    
    ccSize :: [Int] -> Integer
    ccSize cyclens = fact (sum cyclens) `div` centralizerSize cyclens
    
    repr :: [Int] -> [Int]
    repr cyclens = reprh cyclens 0
      where reprh []     _ = []
            reprh (l:ls) m = [m+1 .. m+l-1] ++ [m] ++ reprh ls (m+l)
    
    act_it :: [Int] -> V -> V
    act_it p v = [ v!!i | i <- p ]
    
    act_ot :: V -> [Int] -> V -> V
    act_ot neg p = zipWith (/=) neg . act_it p
    
    orbit :: ( V -> V ) -> V -> [V]
    orbit act x = x : takeWhile (x /=) (iterate act (act x))
    
    orbitLengths :: S.Set V -> ( V -> V ) -> [Int]
    orbitLengths o act = sort $ orblens o act
      where orblens o act
              | S.null o  = []
              | otherwise = let orb = orbit act (S.findMin o)
                            in length orb :
                               orblens (S.difference o (S.fromList orb)) act
    
    oeis725 :: Int -> Integer
    oeis725 n =
      let v = replicateM n [False,True]
          o = S.fromList v
          m = M.fromListWith (+)
              [ (pcls, centralizerSize pcls * ccSize cls) |
                cls <- parts n,
                let pcls = orbitLengths o (act_it $ repr cls) ]
      in sum [ M.findWithDefault 0 (orbitLengths o (act_ot neg p)) m |
               p <- permutations [0..n-1], neg <- v ]
         `div` ( (fact n)^2 * 2^n )
    
    f n = oeis725 (n+1)
    

    Next sequence

    Try it online!

    The math behind it

    Let V be the set of the 2^n boolean vectors of length n (which is also a group under component-wise xor), and P be the group with the (2^n)! permutations of V. Let S be the symmetric group on n points of size n!. S acts on V by permuting the components, thus embedding S in P. Let IT (for input transformations) be this subgroup of P. For the output transformations OT < P, we combine the action of S and the xor-ing action of V on itself. (Abstractly, it is a semidirect product of V and S. It's order is n!*2^n)

    Now let the direct product OT*IT act on P by p(ot,it)=ot^-1*p*it (ot is inverted for formal reasons that are not important here). We want to know how many orbits this action has. To use Burnside's lemma, we need to know how many elements of P are fixed under the action of a particular (ot,it), that is, how many satisfy ot^-1*p*it=p, which is equivalent to p*it*p^-1=ot. So there are only solutions if it and ot are conjugate in P, which means they need to have the same cycle lengths. Then, the number of solutions is the size of the centralizer of it (or ot) in P, which can be computed from the cycle lengths.

    Instead of running over all elements of OT*IT and summing the corresponding number of fixed elements, we can run only over OT and sum the product of the number of conjugate elements in IT and the centralizer size. These products can be precomputed for each conjugacy class of IT represented by the cycle lengths.

    In GAP I would only run over the conjugacy classes of OT, but here I'm too lazy. This program is already good enough to compute more values than OEIS has.

    Christian Sievers

    Posted 2017-07-21T15:00:01.030

    Reputation: 6 366

    7

    229. FMSLogo, 1147 bytes, A000361

    Number of byte: 1132 (code) + 15 (flags) = 1147. Avoid confusing the code snippet.

    Need parameter -h 8200 -w 8200 to enlarge the canvas size.

    to size ; Constant. Must be power of 2
        op 4096
    end
    
    to draw :halfedge :maincol :altcol
        if :halfedge < 4 [stop] ; all fractals need base case
        draw :halfedge / 2 :maincol :altcol
        fd :halfedge rt 60
        fd :halfedge rt 60
        draw :halfedge / 2 :altcol :maincol
        rt 60
        drawtria :halfedge :maincol
        rt 60
        draw :halfedge / 2 :altcol :maincol
        fd :halfedge rt 120 bk :halfedge
    end
    
    to drawtria :edge :col
        if :edge <> 4 [stop]
        setpc :col
        pd
        repeat 3 [fd :edge rt 120]
        pu
        rt 30 fd :edge/2
        setfc :col
        fill
        bk :edge/2 lt 30
    end
    
    to main :index
        make "index :index + 1 ; Must be 0-based
        pu home ht
        bk size rt 90 bk size lt 60
        if not namep "drawn [
            draw size "purple "gray
            make "drawn "
        ]
        fd 8 * :index
        rt 150
        fd 4 * (sqrt 3) / 2 * (4 / 3) ; Go to the centroid of the next triangle
        localmake "result 0
        while [ycor > -size - 10] [
            if pixel = [128 0 128] [make "result :result * 2 + 1] ; purple
            if pixel = [128 128 128] [make "result :result * 2] ; gray
            fd 8 * (sqrt 3) / 2
        ]
        op :result
    end
    

    Testing:

    print main 10
    

    Unfortunately, no implementation of the Logo programming language I can find include the function pixel (used to retrieve pixels on the screen), and FMSLogo appear to be limited to Windows. However JSLogo can draw the fractal.

    However, this code is likely to take forever to run on FMSLogo. For testing purposes:

    • Change the 4096 in size procedure to 128.
    • Don't pass that parameter, it is unnecessary in case of size = 128.
    • For JSLogo, type to setfc :col end
    • Remove the line if :edge <> 4 [stop] so that all triangles are drawn, and not just size-4 ones.

    Explanation:

    1. What is that sequence: See this image for details. Basically the sequence is binary representation of the columns of congruent triangles. Also the pattern is defined like this (drawn lines indicates symmetry axes of the triangles).
    2. Why is Logo useful here: Because Logo has built-in turtle graphics. So draw the fractal at smaller size and rotated is not problem for Logo. After drawing, you just need to read the pixels.

    Next Sequence

    user202729

    Posted 2017-07-21T15:00:01.030

    Reputation: 14 620

    7

    250. Coconut, 711 bytes, A000171

    from collections import Counter
    from math import gcd, factorial
    
    def sparts(n, m=4):
      if n%2==1:
        return [ [1] + p for p in sparts(n-1) ]
      elif n==0:
        return [ [] ]
      elif n<m:
        return []
      else:
        return [ [m] + p for p in sparts(n-m,m) ] + sparts(n,m+4)
    
    def ccSize(l) =
      centSize = [ val**mult * factorial(mult)
                   for val, mult in Counter(l).items() ] |> reduce$(*)
      factorial(sum(l)) // centSize
    
    def edgeorbits(l) =
      samecyc = sum(l) // 2
      diffcyc = sum ([ gcd(l[i],l[j])
                       for i in range(len(l)) for j in range(i) ])
      samecyc + diffcyc
    
    def a(n) =
      sum ([ ccSize(l)*2**edgeorbits(l)
             for l in sparts(n)         ]) // factorial(n)
    
    def f(n) = a(n+1)
    

    Try it online!

    Next sequence

    This can easily compute more values than the 31 that OEIS has.

    Once again we have a symmetric group acting on nodes, inducing an action on the set of possible edges and on graphs. It acts on the set of self-complementary graphs, but I don't see how to count how many of these are fixed by a given permutation to apply the lemma that is often named after Burnside. So instead I use the formula in the comment of the OEIS entry that says that the number of self-complementary graphs with n nodes is equal to the difference of the number of graphs with n nodes with an even number of edges and with an odd number of edges. The symmetric group acts on these sets of graphs as well. Instead of computing both numbers independently, we will consider the cases of an even number and an odd number of edges in parallel, which will turn out to be simpler and allow optimizations. We'll see that "evaluate the graph polynomial at -1" will lead to the same result.

    As usual, we take the sum over the group elements in Burnside's lemma conjugacy class wise, and represent the conjugacy classes by partitions of n. For each conjugacy class, we want to know the difference between the numbers of graphs with an even and odd number of edges that is fixed by a permutation from that class.

    Assume we are given a concrete permutation g. The group generated by g acts on the set of possible edges and partitions them into orbits. A graph is fixed by g if for each orbit, it contains either all or none of its edges. Let's look at the orbits. Each edge in one orbit has its endpoints in the same two (possibly same) cycles of g.

    Let's first assume the endpoints are from the same cycle of length k>=2. If k is odd, then there are (k-1)/2 orbits of length k. If k is even, then there are k/2-1 orbits of length k and one of length k/2 (for example, if g contains the cycle (123456), then the there is an edge orbit of size 3 containing {1,4}). Note that we get all orbits of even size exactly when k is a multiple of four.

    Next consider the case that the endpoints are from different cycles of lengths k and l. Then the orbit has size lcm(k,l), and there are gcd(k,l) such orbits.

    In order to combine all the possibilities, consider the product, for each edge orbit, of 1+x^r, where r is the size of the corresponding orbit. The coefficient of x^s of the product gives the number of graphs that are fixed by g and have s edges. We want the sum of the coefficients at even exponents minus the sum of them at odd coefficients, which we get by evaluating the polynomial at x=-1.

    If we kept the polynomials and added them together, we'd get the graph polynomial. Instead, we don't even create these polynomials, but do the substitution immediately. For an edge orbit of even size, we get a factor of 2, for an odd size we get 0. (There is also a direct combinatorial argument that if there is an edge orbit of odd size then there are as many fixed graphs with an even number of edges as there are with an odd number of edges. And the factor 2 corresponds to the choice of including the edges of one orbit to the fixed graph or not).

    So, by the considerations about edges with points from only one cycle, we get a difference of 0 whenever g contains a cycle of odd length greater than one, or a cycle of even length not divisible by four. We also get a difference of 0 whenever g contains at least two fixed points (cycles of length one).

    This means we only need to sum over conjugacy classes with at most one fixed point and all other cycle lengths multiples of four. sparts computes the corresponding partitions of n. There are none unless n is of the form 4k or 4k+1, so in the other cases there are no self-complementary graphs, which can also easily seen by noting that in these cases the total number of possible edges is odd. But this observations alone doesn't lead to the optimization of only considering special partitions, of which there are only as much as there are partitions of k.

    ccSize computes the size of a conjugacy class with given cycle lengths. edgeorbits computes the number of edge orbits of the action of the group generated by a permutation with the given cycle lengths, assuming they are of the special form. In the general case, samecyc, the number of edge orbits with edges that have both nodes from the same cycle, could not be calculated like this. (When I wrote the code, I didn't notice that it only depends on n in the relevant cases.)

    a puts everything together, and f fixes the different indexing.

    Christian Sievers

    Posted 2017-07-21T15:00:01.030

    Reputation: 6 366

    This looks like Python with a touch of JavaScript added :P – caird coinheringaahing – 2017-11-12T19:07:44.917

    @ChristianSievers I'm stupid. Anyway, don't forget that some PPCGers have OEIS accounts and could add more values to A000171 :) – Stephen – 2017-11-12T21:38:18.653

    @Stephen I consider doing that – Christian Sievers – 2017-11-12T22:11:27.133

    Can you explain what algorithm are you using and/or what does the abbreviated function names (sparts, ccSize) means? – user202729 – 2017-11-13T14:17:33.680

    @user202729 I finally added some explanation. – Christian Sievers – 2017-11-15T18:18:53.590

    Thanks! / Can you explain what's the difference between "cycle" and "orbit"? "cycle" applies to vertices while "orbit" applies to edges? Also, what is "the graph polynomial"? – user202729 – 2017-11-19T09:35:45.727

    @user202729 Here "cycle" refers to the basic elements of cycle notation for permutations, e.g. the permutation g=(12)(3456) has cycles (12) and (3456). The orbits depend on an action of a group on a set, two elements belong to the same orbit if there is a group element which transforms one to the other. E.g. the action of the group generated by g on edges has as orbits {{3,4},{4,5},{5,6},{4,6}} and {{1,4},{2,5},{1,6},{2,3}} and three more. I mostly discuss egde orbits; node orbits indeed correspond to cycles. "graph polynomial" as in @KSmart's comment to you under the last answer. – Christian Sievers – 2017-11-19T12:20:07.783

    7

    265. brainfuck, 636 Bytes, A000102

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

    Input is a normal decimal number.

    Note that the result is calculated modulo the cell size, so for TIO 256, but it works for other cell sizes as well.

    Try it online!


    Explanation:

    Relies on the recursive definition a(n) = 2*a(n-1) + a(n-2) - 2*a(n-4) - 3*a(n-5) - 2*a(n-6) - a(n-7)

    [-]>[-]+[[-]>[-],[+[-----------[>[-]++++++[<------>-]<--<<[->>++++++++++<<]>>[-<<+>>]<+>]]]<]<
    

    takes input (decimal value in ASCII) and write actual decimal number in a cell. Taken from the esolang site listing BF algorithms.

    <<<<<+<++<+++++>>>>>>> 
    

    initialize first seven values (0, 0, 0, 0, 1, 2, 5)

    Then comes the main block. Basically the seven cells to the left of the input represent a(n) a(n-1) a(n-2) a(n-3) a(n-4) a(n-5) a(n-6) and the input represents how many 'window shifting' operations have to be performed still, where a window shifting operation consists of a(n-6)=a(n-5), a(n-5)=a(n-4) etc. and the calculation of the new a(n)(so a(n+1) in terms of our old labels) as described above. The former (a-6) is dropped.

    <[-<<<<<<<+>>>>>>>]
    

    Move a value seven cells left, do this for all sequence terms. Then we move to the former a(n) with value x and execute

    [>>>>>>>++ >+< <<<<<<<-]
    

    which increases the new value of a(n) by 2*x and the value of a(n-1) by x. Repeat the same for the other sequence values with the corresponding factor for a(n).

    Finally, move back to the input, decrease it by 1. If input is zero, we're done with the main block. If not, execute another window shift operation.

    <<[-]<[-]<[-]<[-]<[-]<[-]>>>>>>
    

    Zero all the sequence numbers not required for the final output. (This is not necessary, but I like to do it anyway to make sure it does not interfere with the output function.

    [>>+>+<<<-]>>>[<<<+>>>-]<<+>[<->[>++++++++++<[->-[>+>>]>[+[-<+>]>+>>]<<<<<]>[-]
      ++++++++[<++++++>-]>[<<+>>-]>[<<+>>-]<<]>]<[->>++++++++[<++++++>-]]<[.[-]<]<
    

    Lastly, output the number left to the input which started as a(0), so it is a(n)after n window shifts. The algorithm for this is again taken from the esolangs site linked above.


    This window shifting algorithm is generally quite efficient, but this implementation can be optimized a lot.

    For some input n, we do n window shifts, but after that our lowest stored value is a(n), which means we already calculated a(n+6). This is obviously inefficient but saves the special handling required for inputs <7, so it saves some characters and mainly nerves of the programmer.

    Second, it is not necessary to copy the whole sequence. It'd be sufficient to copy one value, but this way it's more convenient to write and understand.

    Here is a solution implementing the second optimization. Only the old a(n) is moved. The other values move one spot to the right and their corresponding multiple is added/subtracted in one loop. This actually saves more time then I expected for larger values with unbounded cell size.


    Next sequence: A000636

    PattuX

    Posted 2017-07-21T15:00:01.030

    Reputation: 361

    Could you please add a link to the next sequence in order to help the next answerer? – caird coinheringaahing – 2017-11-25T01:10:23.343

    Personally I find the recurrence relation somewhat magical. – user202729 – 2017-11-25T13:39:14.947

    I think I know how to calculate the next sequence, but I don't know how to enumerate unrooted trees without duplicates, so I'll leave this here: for brevity, let's define a branch as a non-leaf element of a tree. The value of the sequence for the index n is the sum of "scores" of all unrooted ternary trees with n branches. The score of a tree is defined as c² – c + d, where c is the number of branches with at least one leaf, and d is the number of branches with at least two leaves – NieDzejkob – 2017-11-27T07:55:33.283

    Clarification: the trees are unordered and unlabelled – NieDzejkob – 2017-11-27T09:42:28.413

    Honestly I didn't look at the next sequence at all. But there's a g.f. in terms of A000642 which in turn has a g.f. in terms of A000598 which can be defined by positive integer solutions for a polynomial. I haven'z checked that, but if it's true, it should be fairly easy to implement in most languages. And I just noticed A000642 has a Mathematica implementation and A000598 has a Maple solution. So it should be definetely possible. – PattuX – 2017-11-27T19:20:27.763

    @NieDzejkob Deduplicate by tree isomorphism. Unacceptably slow. Tree centroid / center can be somehow useful here, but I don't know. / Actually two X atoms are "special" in comparison with the remaining 2n H atoms, which explains the scoring. – user202729 – 2017-11-28T03:01:55.487

    Also I guess that is often called "rooted subtree"? I'm not sure. – user202729 – 2017-11-28T03:02:29.383

    @user202729 I know where the scoring comes from because I came up with it. I'll look into the g.f. some more... – NieDzejkob – 2017-11-28T08:09:50.513

    7

    271. Java 6, 10008 bytes, A000103

    This program was written entirely by user202729. I am posting this with the creator's explicit permission / request.

    /*
    Edit: Why must I map from Edge to index, 
    and then get edge from index, 
    while I can map Edge to Edge? Fixed.
    --------
    Edit 2: Remove some dependency on ArrayList.get.
    --------
    Edit 3: Remove a factor of n! because I didn't think
    about this efficient graph isomorphism checking.
    ---------
    Ok... the solution turns out to be too short now to
    get to 10008 bytes. Therefore I'm going to add some
    random things here.
    
    #############################################
    #############################################
    #############################################
    #############################################
    #############################################
    #############################################
    #############################################
    #############################################
    */
    
    import java.util.ArrayList;
    import java.util.List;
    import java.util.Map;
    import java.util.IdentityHashMap;
    import java.util.Scanner;
    
    public class Main {
    	
    	static class Edge {
    		Edge next, prev, twin;
    		final int node;
    		Edge(int node) {
    			this.node = node;
    		}
    		Edge pairNext(Edge e) {
    			this.next = e; e.prev = this;
    			return this;
    		}
    		Edge pairTwin(Edge e) {
    			this.twin = e; e.twin = this;
    			return this;
    		}
    	}
    	
    	static class Graph {
    		List<Edge> edges;
    		int nVertices;
    		
    		/** 
    		 * Initialize to a tetrahedral graph.
    		 */
    		Graph () {
    			nVertices = 3;
    			
    			edges = new ArrayList<Edge>();
    			
    			edges.add(new Edge(0));
    			edges.add(new Edge(1));
    			edges.add(new Edge(2));
    			edges.get(0).pairNext(edges.get(1));
    			edges.get(1).pairNext(edges.get(2));
    			edges.get(2).pairNext(edges.get(0));
    			
    			edges.add(new Edge(1));
    			edges.add(new Edge(2));
    			edges.add(new Edge(0));
    			edges.get(3).pairTwin(edges.get(0)).pairNext(edges.get(5));
    			edges.get(4).pairTwin(edges.get(1)).pairNext(edges.get(3));
    			edges.get(5).pairTwin(edges.get(2)).pairNext(edges.get(4));
    			
    			addVertex(new Edge[] {
    				edges.get(0), edges.get(1), edges.get(2)
    			});
    		}
    		
    		/** 
    		 * Copy the other graph.
    		 * Expected time complexity O(n) where n is the number of edges
    		 * in the graph.
    		 * @param other The other graph.
    		 */
    		Graph (Graph other) {
    			nVertices = other.nVertices;
    			edges = new ArrayList<Edge>(other.edges.size()); // initial capacity
    			Map<Edge, Edge> map = new IdentityHashMap<Edge, Edge>();
    			for (Edge e : other.edges) {
    				Edge f = new Edge(e.node);
    				edges.add(f);
    				map.put(e, f);
    			}
    
    			assert other.edges.size() == edges.size();
    
    			for (Map.Entry<Edge, Edge> ef : map.entrySet()) {
    				Edge e = ef.getKey(), f = ef.getValue();
    				f.prev = map.get(e.prev);
    				f.next = map.get(e.next);
    				f.twin = map.get(e.twin);
    			}
    		}
    		
    		/**
    		 * Find circuit from one edge.
    		 * Note that if the circuit length is less than {@code n}, {@code null}
    		 * is also returned.
    		 * @param e The input edge.
    		 * @return An edge array of length {@code n} consists of node indices, 
    		 * or {@code null} if not found.
    		 */
    		Edge[] findCircuit (Edge e, int n) {
    			
    			assert edges.contains(e);
    			
    			Edge[] circuitEdges = new Edge[n];
    			circuitEdges[0] = e;
    			for (int i = 1; i < n; ++i) {
    				circuitEdges[i] = circuitEdges[i-1].next;
    				
    				assert circuitEdges[i].prev == circuitEdges[i-1];
    			}
    			return circuitEdges[n - 1].next == e ? circuitEdges : null;
    		}
    		
    		/**
    		 * Add an vertex to the plane bounded by {@code circuit}. <br>
    		 * The vertex will be connected to all of the vertices inside the 
    		 * circuit. <br>
    		 * Time complexity: O({@code circuit.length}).
    		 * @param circuit The specified plane. Should be listed in the order
    		 * such that {@code circuit[i].next == circuit[(i+1) % nVertices]}
    		 * for all valid {@code i}.
    		 */
    		void addVertex(Edge[] circuit) {
    			int n = edges.size(), k = circuit.length;
    			
    			for (int i = 0; i < k; ++i) {
    				assert(circuit[i].next == circuit[(i+1)%k]);
    				assert(circuit[(i+1)%k].prev == circuit[i]);
    			}
    			
    			for (int i = 0; i < k; ++i) edges.add(
    					new Edge(nVertices)
    					.pairNext(circuit[i])
    			);
    			for (int i = 0; i < k; ++i) edges.add(
    					new Edge(circuit[i].node)
    					.pairTwin(edges.get(n + i))
    					.pairNext(edges.get(n + (i == 0 ? k : i) - 1))
    			);
    			for (int i = 0; i < k; ++i) 
    				circuit[i].pairNext(edges.get(n + (i == k-1 ? i : i + k) + 1));
    			
    			++nVertices;
    		}
    		
    		/**
    		 * Remove an edge from the graph. <br>
    		 * Time complexity O({@code edges.size()}).
    		 * @param edge The edge to remove.
    		 */
    		void removeEdge(Edge edge) {
    
    			assert edges.contains(edge);
    			
    			Edge twin = edge.twin;
    			twin.prev.pairNext(edge.next);
    			edge.prev.pairNext(twin.next);
    			
    			// it is possible to implement this in O(1) with LinkedList but I'm lazy...
    			boolean success = edges.remove(edge);
    			success = edges.remove(twin) && success; 
    			assert success;
    			
    		}
    		
    		/**
    		 * Calculate the minimum degree of any vertex.
    		 * @return The minimum degree of any vertex.
    		 */
    		int minVertexDegree() {
    			int[] degree = new int[nVertices];
    			for (Edge e : edges) ++degree[e.node];
    			
    			int ans = degree[0];
    			for (int d : degree)
    				if (d < ans) ans = d;
    			
    			return ans;
    		}
    		
    		/**
    		 * Check isomorphism between two graphs (reflection does not count).
    		 * @param g Other graph.
    		 * @return whether the graphs are isomorphic under rotation.
    		 */
    		boolean isomorphicToWithoutReflection(Graph g) {
    			check_edge_equivalence:
    			for (Edge e : edges) {
    				Map<Edge, Edge> map = new IdentityHashMap<Edge, Edge>();
    				map.put(e, g.edges.get(0));
    				
    				/**
    				 * List containing edges which are mapped, but their neighbors 
    				 * ({@code next, prev, twin} are not mapped.
    				 */
    				List<Edge> pending = new ArrayList<Edge>(); 
    				pending.add(e);
    				
    				while (!pending.isEmpty()) {
    					Edge f = pending.remove(pending.size() - 1), map_f = map.get(f);
    					for (Edge[] adj : new Edge[][]{
    						{f.next, map_f.next},
    						{f.prev, map_f.prev},
    						{f.twin, map_f.twin}
    					}) {
    						Edge map_adj = map.get(adj[0]);
    						if (map_adj == null) {
    							map.put(adj[0], adj[1]);
    							pending.add(adj[0]);
    						} else {
    							if (map_adj != adj[1]) 
    								continue check_edge_equivalence;
    						}
    					}
    				}
    				
    				assert map.size() == edges.size(); // the graph is connected
    				return true;
    			}
    			return false;
    		}
    		
    		/**
    		 * Reflect this graph.
    		 */
    		void reflect() {
    			for (Edge e : edges) {
    				Edge f = e.prev; e.prev = e.next; e.next = f;
    			}
    		}
    
    		/**
    		 * Check isomorphism between two graphs.
    		 * Algorithmic complexity: O(n<sup>2</sup>).
    		 * @param g The graph to check isomorphism with {@code this}.
    		 * @return {@code true} if the graphs are isomorphic,
    		 * {@code false} otherwise.
    		 */
    		boolean isomorphicTo(Graph g) {
    			boolean ans = false;
    			for (int i = 0; i < 2; ++i) {
    				ans = ans || isomorphicToWithoutReflection(g);
    				reflect();
    			}
    			return ans;
    		}
    	}
    	
    	/**
    	 * Given a graph with length {@code n}, generate all graphs with length 
    	 * {@code n+1} using the approach in MishaLavrov's answer to 
    	 * HyperNeutrino's question on Math.SE about A000109
    	 * @param graph The input graph.
    	 * @return A List of graphs.
    	 */
    	static List<Graph> generateGraph(Graph graph) {
    		ArrayList<Graph> result = new ArrayList<Graph>();
    		
    		// case 1: add vertex to list of 3 edges
    		for (int i = 0; i < graph.edges.size(); ++i) {
    			Edge edge = graph.edges.get(i);
    			
    			if (!(edge.node < edge.next.node && edge.node < edge.prev.node))
    				continue; // avoid redundancy, for each triangular face 
    			// only consider the edge with minimum node index
    			
    			Graph newgraph = new Graph(graph);
    			edge = newgraph.edges.get(i);
    
    			Edge[] circuit = newgraph.findCircuit(edge, 3);
    			assert circuit != null; // the graph is supposed to be triangular 
    			// decomposition of a sphere.
    			
    			newgraph.addVertex(circuit);
    			result.add(newgraph);
    			
    		}
    		
    		// case 2: add vertex to 2 adjacent triangular faces
    		for (int i = 0; i < graph.edges.size(); ++i) {
    			Edge edge = graph.edges.get(i);
    
    			Edge twin = edge.twin;
    			if (edge.node > twin.node) continue;
    			
    			assert graph.findCircuit(edge, 3) != null;
    			assert graph.findCircuit(twin, 3) != null;
    			
    
    			Graph newgraph = new Graph(graph);
    			edge = newgraph.edges.get(i);
    
    			Edge next = edge.next;
    			newgraph.removeEdge(edge);
    			Edge[] circuit = newgraph.findCircuit(next, 4);
    			assert(circuit != null);
    			newgraph.addVertex(circuit);
    
    			result.add(newgraph);
    		}
    		
    		// case 3: add vertex to 3 adjacent triangular faces
    		for (int i = 0; i < graph.edges.size(); ++i) {
    
    			Edge edge = graph.edges.get(i);
    			if (edge.twin.next.twin == edge.prev.twin.prev) continue;
    			
    			Graph newgraph = new Graph(graph);
    
    			edge = newgraph.edges.get(i);
    			Edge next = edge.next, prev = edge.prev;
    			assert newgraph.findCircuit(edge, 3) != null;
    			
    			newgraph.removeEdge(edge); newgraph.removeEdge(prev); 
    			Edge[] circuit = newgraph.findCircuit(next, 5);
    			assert(circuit != null);
    			newgraph.addVertex(circuit);
    
    			result.add(newgraph);
    			
    		}
    		
    		return result;
    	}
    	
    	/**
    	 * Evolve the graphs with number of node {@code n} to get graphs with 
    	 * number of node {@code n+1}.
    	 * @param graphs The list of graphs with {@code n} nodes.
    	 * @return A list of graphs with {@code n+1} nodes.
    	 */
    	static List<Graph> evolve(List<Graph> graphs) {
    		List<Graph> result = new ArrayList<Graph>();
    		
    		for (Graph graph : graphs) {
    			outer: for (Graph g0 : generateGraph(graph)) {
    				
    				assert(g0.nVertices == graph.nVertices + 1);
    				
    				for (Graph g1 : result) {
    					if (g0.isomorphicTo(g1))
    						continue outer;
    				}
    				result.add(new Graph(g0));
    			}
    		}
    		
    		return result;
    	}
    	
    	public static void main(String[] args) {
    		Scanner in = new Scanner(System.in);
    		int n = in.nextInt();
    		
    		List<Graph> graphs = new ArrayList<Graph>();
    		graphs.add(new Graph());
    		
    		for (int i = 0; i < n; ++i) graphs = evolve(graphs);
    		
    		int ans = 0;
    		for (Graph g : graphs) {
    			if (g.minVertexDegree() >= 4) ++ans;
    		}
    		
    		System.out.println(ans);
    	}
    }
    
    

    Try it online!

    Note: TIO runs the program on Java 9, but I've tested running the program on Java 6u45 - Windows 32 bit locally, and it also works. Input 5 gives output 5 in about 21 seconds now, and input 6 gives output 12 in 7 minutes 14 seconds.

    Next Sequence

    HyperNeutrino

    Posted 2017-07-21T15:00:01.030

    Reputation: 26 575

    This sequence would be a good candidate for hardest sequence to golf

    – pppery – 2019-07-11T23:55:22.100

    7

    318. Funciton, 1688 bytes, A000652

    ╔═══╗  ┌─────────╖  ┌─┐ ┌───╖  ╔═══╗
    ║   ╟──┤ str→int ╟──┤ └─┤ ↑ ╟──╢ 2 ║
    ╚═══╝  ╘═════════╝  │   ╘═╤═╝  ╚═══╝
      ┌─────────────────┘     │
    ┌─┴┐                      │
    │┌─┴─╖                ┌───┴───┐
    ││ ♭ ║              ┌─┴─╖   ┌─┴─╖  
    │╘═╤═╝┌───╖    ╔═══╗│ ♭ ║   │ ! ║  
    │  └──┤ ↑ ╟────╢ 2 ║╘═╤═╝   ╘═╤═╝
    │     ╘═╤═╝    ╚═╤═╝  │       │
    │    ┌──┴─┐      │    └───┐   │
    │  ┌─┴─╖  │┌───╖ │  ┌───╖ │   │
    │  │ ! ║  └┤ ↑ ╟─┴──┤ ↑ ╟─┘   │
    │  ╘═╤═╝   ╘═╤═╝    ╘═╤═╝     │
    │    │ ┌───╖ │   ┌───╖│       │
    │    └─┤ × ╟─┘ ┌─┤ × ╟┘       │
    │      ╘═╤═╝   │ ╘═╤═╝ ┌───╖  │
    │  ╔═══╗ └─────┘   └───┤ + ╟──┘
    │  ║ 2 ╟┐              ╘═╤═╝
    │  ╚═╤═╝│        ┌───╖   │
    │    │  └──┐   ┌─┤ ÷ ╟───┘
    │    └──┐┌─┴─╖ │ ╘═╤═╝┌─────────╖
    │ ┌───╖ ││ ↑ ╟─┘   └──┤ int→str ╟─
    └─┤ × ╟─┘╘═╤═╝        ╘═════════╝
      ╘═╤═╝    │
        └──────┘
    

    Next Sequence

    Calculates the formula from the OEIS page. I'm sure there's a more compact way to do this, without multiple 2 constants, but this took me long enough.

    Try it online!

    KSmarts

    Posted 2017-07-21T15:00:01.030

    Reputation: 1 830

    6

    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

    Mr. Xcoder

    Posted 2017-07-21T15:00:01.030

    Reputation: 39 774

    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 – 2017-07-21T15:46:10.300

    I don't get what this sequence is about at all. Could someone explain it simply? – geokavel – 2017-07-21T15:47:58.723

    1

    @geokavel See this challenge

    – Mr. Xcoder – 2017-07-21T15:49:11.550

    6

    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

    Conor O'Brien

    Posted 2017-07-21T15:00:01.030

    Reputation: 36 228

    Next sequence is...? – Mr. Xcoder – 2017-07-21T19:20:32.783

    How are we supposed to do an erroneous sequence? – MD XF – 2017-07-21T19:20:55.977

    C'mon, you left us with the broken one??? – HyperNeutrino – 2017-07-21T19:21:05.300

    Fixing........... – Conor O'Brien – 2017-07-21T19:21:35.400

    Please change this one's byte cont, because the next one is broken

    – Mr. Xcoder – 2017-07-21T19:21:41.807

    Technically you could hard code it but ok – Conor O'Brien – 2017-07-21T19:21:57.620

    Oh, the next one is hell – Mr. Xcoder – 2017-07-21T19:22:30.833

    @Mr.Xcoder it isn't really hell compared to A60 :D – Leaky Nun – 2017-07-21T19:22:43.417

    @LeakyNun and you didn't even get credit for it because you were writing your explanation :P – Stephen – 2017-07-21T19:23:07.010

    Next one may be perfect for Brachylog, though I don't know it so I couldn't say for sure... – ETHproductions – 2017-07-21T19:26:13.257

    At least I left you guys with A19 @StepHen – Leaky Nun – 2017-07-21T19:26:23.953

    @LeakyNun and I woulda gone to http://oeis.org/A000006

    – Stephen – 2017-07-21T19:27:46.920

    6

    31. Joy, 172 bytes, A001112

    DEFINE acf == [20 <] [[0 1 1 3 4 11 136 283 419 1121 1540 38081 39621 117323 156944 431211 5331476 11094163 16425639 43945441] of] [10 - dup 10 -] [[39202 *] dip -] binrec.
    

    Try it online!

    Next sequence

    alephalpha

    Posted 2017-07-21T15:00:01.030

    Reputation: 23 988

    How does it work? – Leaky Nun – 2017-07-22T04:25:48.937

    @LeakyNun a(0)=0, a(1)=1, ..., a(19)=43945441. For n>19, a(n)=39202*a(n-10)+a(n-20). It is based on the MAGMA code on OEIS. – alephalpha – 2017-07-22T04:39:44.857

    6

    caird coinheringaahing

    Posted 2017-07-21T15:00:01.030

    Reputation: 13 702

    6

    50. Japt, 26 bytes, A000074

    1o2pU 2 èÈo f_¬v1Ãd_nX ¬v1
    

    Try it online!

    Next sequence (I was quite tempted to ungolf it by 1 byte to get A000027, but this one should be fine)

    Explanation

    1o2pU 2 èÈ  o f_  ¬ v1à d_  nX ¬ v1
    1o2pU 2 èX{Xo fZ{Zq v1} dZ{ZnX q v1}}   Ungolfed
                                            Implicit: U = input integer
      2pU                                   Yield 2 ** U.
    1o    2                                 Create the range [1, 3, 5, ..., 2**U - 1].
            èX{                         }   Find the number of items X where this is true:
               Xo                             [0, 1, ..., X - 1]
                  fZ{     }                   filtered to only items Z where
                     Zq v1                      sqrt(Z) is divisible by 1 (Z is square)
                                              (this gives a list of the squares less than X)
                            dZ{        }      contains an item Z where
                               ZnX              X - Z
                                   q v1         is also square.
                                              In other words, assert that an integer solution
                                              to X = a**2 + b**2 exists.
                                            This gives the number of odd integers less than 2**U
                                            that can be represented as the sum of two squares.
                                            Implicit: output result of last expression
    

    ETHproductions

    Posted 2017-07-21T15:00:01.030

    Reputation: 47 880

    6

    69. GAP, 333 bytes, A000761

    dirs:=[[1,0,0],[0,1,0],[0,0,1]];
    dirs:=Concatenation(dirs,-dirs);
    
    count:=function(pos,seen,n)
      local newseen;
      if (pos in seen) or AbsInt(pos[1]-2)>n then
        return 0;
      fi;
      if n=0 then
        return 1;
      fi;
      newseen:=Concatenation(seen,[pos]);
      return Sum(dirs,d->count(pos+d,newseen,n-1));
    end;
    
    f:=n->count([0,0,0],[],n+2);
    

    Next sequence

    Christian Sievers

    Posted 2017-07-21T15:00:01.030

    Reputation: 6 366

    The partitions don't stop, do they? – tomsmeding – 2017-07-23T15:47:27.730

    Solution to the next one – BlackCap – 2017-07-23T16:29:04.227

    1I'd just let g x n|x<0=0 | otherwise =1+sum(takeWhile(>0)([g(x-sqrt k)k|k<-[n..]])) and call g(n+1)1 - 1. BTW, I wonder how to do it without relying on floating point arithmetics. – Christian Sievers – 2017-07-23T16:55:55.643

    6

    80. Mathics, 140 Bytes, A000013

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

    Try it Online!

    Next Sequence

    KSmarts

    Posted 2017-07-21T15:00:01.030

    Reputation: 1 830

    Wellp, I'll be waiting for 81 https://oeis.org/A000140 hah.

    – Magic Octopus Urn – 2017-07-24T19:26:37.793

    @MagicOctopusUrn It's actually not that hard. If you understand Jelly, it's just !ḶÆ!S€ĠL€Ṁ

    – ETHproductions – 2017-07-24T20:53:16.950

    @ETHproductions was looking to do an 05AB1E entry :P. – Magic Octopus Urn – 2017-07-24T21:07:22.743

    6

    81. Röda, 290 bytes, A000140

    fact n {
      b = 2
      x = 0
      while [ n > 0 ] do
        x += n % b
        n = floor(n / b)
        b += 1
      done
      return x
    }
    
    A000140 n {
      x = 1; q = n; while [ q > 0 ] do x *= q; q -= 1; done
      t = 0
      while [ x > 0 ] do
        x -= 1
        t += 1 if [ fact(x) = floor(n * (n-1) / 4) ]
      done
      return t
    }
    

    Try it online!

    Next sequence

    Each item in A000140 is the largest number of permutations of a length-n array all having the same inversion count. This may sound daunting, but it's really not. Here's the table of possible inversions for n = 3:

        [inv. table]  [permutation]  inversion count
    0:     [ 0 0 ]      [ 0 1 2 ]    0
    1:     [ 1 0 ]      [ 1 0 2 ]    1
    2:     [ 0 1 ]      [ 0 2 1 ]    1
    3:     [ 1 1 ]      [ 2 0 1 ]    2
    4:     [ 0 2 ]      [ 1 2 0 ]    2
    5:     [ 1 2 ]      [ 2 1 0 ]    3
    

    1 permutation has zero inversions, 2 permutations have one inversion each, 2 others have two inversions each, and 1 has three. The maximal number of permutations with x inversions is 2, shared by x = 1 and x = 2, so the output is 2.

    Now don't get concerned; we don't have to calculate all permutations of a length-n array. You may have noticed that each inversion table (in the second-to-left column) sums to the number of inversions of that permutation. Also, it turns out calculating the sum of the inversion table for a permutation index k is remarkably simple: just convert k to the factorial base and sum the digits. Examples:

     k: [fact. digits]  sum
     0: [          0 ]  0
     1: [          1 ]  1
     2: [        1 0 ]  1
     3: [        1 1 ]  2
     4: [        2 0 ]  2
     5: [        2 1 ]  3
     6: [      1 0 0 ]  1
     7: [      1 0 1 ]  2
     8: [      1 1 0 ]  2
    ...
    22: [      3 2 0 ]  5
    23: [      3 2 1 ]  6
    24: [    1 0 0 0 ]  1
    25: [    1 0 0 1 ]  2
    ...
    

    This sequence itself is A034968. So to calculate the n-th term in A000140, all you have to do is find the x that appears the most often in the first n! terms of the factorial digit sum sequence, then return how many times x appears. And you don't even have to find x manually: the OEIS page mentions that it's always floor(n(n-1)/4).

    After I made all of these realizations, implementing it was a piece of cake. The hardest part was learning how Röda itself works, but that was a fun challenge in itself. Thanks @fergusq for the nice language :-)

    ETHproductions

    Posted 2017-07-21T15:00:01.030

    Reputation: 47 880

    NB for an efficient implementation, the first comment on A000140 points you at A008302, which has a nice recurrence. – Peter Taylor – 2018-01-20T10:26:33.337

    6

    116. Kotlin, 1156 bytes, A000273

    import java.math.BigInteger;
    
    fun main(args: Array<String>) {
        val n = Integer.valueOf(args[0]);
        var a = accum(n, n, Array(n, { x -> 0 }), Array(n, { x -> 0 }), 0, BigInteger.ONE, n);
        println(a.first / a.second);
    }
    
    fun accum(n: Int, m: Int, part: Array<Int>, freq: Array<Int>, off: Int, c: BigInteger, omega: Int): Pair<BigInteger, BigInteger> {
        if (n == 0) return Pair(BigInteger.ONE.shiftLeft(omega), c);
        if (m == 0) return Pair(BigInteger.ZERO, BigInteger.ONE);
    
        var sum = accum(n, m - 1, part, freq, off, c, omega);
        part[off] = m;
        freq[off] = 0;
        var c1 = c;
        var omega2 = omega;
    
        var delta = -1;
        var j = 0;
        while (j < off) delta += 2 * freq[j] * gcd(part[j++], m);
    
        var im = m;
        while (im <= n) {
            freq[off]++;
            c1 = c1 * BigInteger.valueOf(im.toLong());
            omega2 = omega2 + 2 * (im - m) + delta;
            val term = accum(n - im, m - 1, part, freq, off + 1, c1, omega2);
            sum = Pair(sum.first * term.second + sum.second * term.first, sum.second * term.second);
            im += m;
        }
    
        return sum;
    }
    
    fun gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b)
    

    Online demo

    Next sequence is a nice easy partition sequence.

    Notes

    This implementation follows J. Qian, Enumeration of unlabeled directed hypergraphs, Electronic Journal of Combinatorics, 20(1) (2013), and in particular exploits corollary 6. Although it may not look it, it's much simpler than the Maple implementation listed in OEIS.

    Peter Taylor

    Posted 2017-07-21T15:00:01.030

    Reputation: 41 901

    6

    123. Emojicode, 278 bytes, A002057

    
     ️➡
      p 1.0
      k⏩2➕1
       ✖p➕➗k 1
      
      p
     
     ️➡
      ➗✖️➕1✖2➕3
     
    
    
    
     ️➕110 10
    
    

    Try it online!

    Next sequence! (have an easy one)

    This is Emojicode 0.5, which is currently the newest version, but I'm mentioning it because of the major changes that are planned for 0.6.

    Explaination:

    Note: a lot of emoji choice doesn't make much sense in Emojicode 0.5. It's 0.x, after all. 0.6 will fix this, so if you want to learn this (because who wouldn't want to), I recommend waiting a moment.

    Emojicode is an object-oriented programming language featuring generics, protocols, optionals and closures, but this program uses no closures and all generics and protocols can be considered implicit, while the only optional appears in the I/O part.

    The program operates on only a few types: is the integer type, is the floating-point type, is the string type and ⏩ is the range type (yes, a range is a type in Emojicode).

    There are currently no operators in Emojicode, so addition, comparsions and other operations that are normally operators are implemented as functions, effectively making the expressions use prefix notation. Operators are also planned in 0.6.

     ... 
    

    Extend the type. This is a feature that is not commonly found in programming languages. Instead of creating a new class with as the superclass, modifies directly. Grapes and watermelons declare code blocks in Emojicode.

    ️➡ ... 
    

    ️ is a method that returns . ️ calculates A000108 using the Product_{k=2..n} (1 + n/k). The OEIS states that the formula is only valid for n > 1, but this method will only be called with n >= 1 and the value is ignored in the n = 1 case because of a multiplication by 0, so no special case is present.

    p 1.0
    

    Create a variable named p and set it to 1.0. This automatically makes the type . This is necessary because fractions are present in the product.

    k⏩2➕1 ... 
    

    iterates over anything that implements the ⚪️ protocol, while ⏩ is a range literal that happens to implement . A range has a start value, a stop value and a step value, which is assumed to be 1 if start < stop, or -1 otherwise. One can also specify the step value by using the ⏭ to create the range literal. The start value is inclusive, while the stop value is exclusive, so this is equivalent to for k in range(2, ➕1). ➕ is a method of the type that adds numbers together and refers to the object the method was called on, so ➕1 means n + 1. This corresponds to the range of Product_{k=2..n} from the formula, since the stop value is not included in the range.

    ✖p ...
    

    This is an assignment by call, which means "call ✖ on p with the arguments (...) and set p to the return value". ✖ is a method of that multiplies numbers together. This can sound familiar, because it's similar to the operators like +=, *= or >>= in some popular emoji-free (and therefore inferior) languages.

    ➕➗k 1
    

    , in addition to being a type, is a method of the type, that returns a of the same value as - by convention, methods that share the name with a type are used to convert to that type. Therefore this expression represents (n / k) + 1, which is then multiplied by, and stored in p.

    p
    

    is used to return values from methods, while is a method of the type that returns the nearest . Whether one uses an equivalent of round, floor or ceil shouldn't matter since the formula always results in integers, but using makes the code more immune to floating-point inaccuracies.

    ️➡ ... 
    

    This creates a method named ️ that returns . This method implements A002057.

    ➗✖️➕1✖2➕3
    

    This is a return statement with the formula "encoded" in prefix notation. If you decipher it, you'll see ️ being called on n + 1, the result multiplied by 2 * n and divided by n + 3, resulting in the formula 2*n*A000108(n+1)/(n+3) from the OEIS.

     ... 
    

    marks the equivalent of a main function.

    ️➕110 10
    

    Let's break it down.

    
    

    marks the beginning and end of a literal. is used for constructing objects, so this creates a with the constructor called with a single argument of an empty string. is used to read a line of input from the user, and the argument is used as a prompt.

    10
    

    is a method of the type, and as you might guess, it converts the string into an integer. It takes one argument, the number base to use.

    10
    

    returns an optional, . Optionals can contain a value of the base type or nothingness, ⚡. When the string doesn't contain a number, ⚡ is returned. To use the value of an optional, one has to unwrap it using , which raises a runtime error if the value is ⚡. Normally it is bad practice to unwrap an optional without checking, but this is codegolf.SE, we don't care. If you want to see an example with error checking, see my answer at this challenge.

    ➕110
    

    The formula used for A002057 appears to have an off-by-one error, so 1 is added to the input to make the offset correct.

    ️➕110
    

    ️ is called on the corrected input, calculating the sequence.

    ️➕110 10
    

    You guessed it. is a method of the type that converts it to a , taking the base as an argument.

    ️➕110 10
    

    Finally, is used to print the result.

    NieDzejkob

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 630

    Wow, what's that? So colourful! – Christian Sievers – 2017-09-01T14:09:19.517

    This is Emojicode, the only serious programming language that's bursting with emoji! Stay tuned for the explaination. – NieDzejkob – 2017-09-01T14:15:29.397

    @ChristianSievers I just thought I'd notify you that now you can learn this beautiful, superior language on my example. – NieDzejkob – 2017-09-01T14:53:01.713

    6

    178. GAP, 933 bytes, A000214

    Luckily GAP wasn't taken for No. 167 (A000638)!

    AG := function( n )
      local b, sw, sh, xr, tr, gens;
      b := BasisVectors(Basis(FullRowSpace(GF(2),n+1)));
      gens := [];
      if n>1 then
        sw := ShallowCopy(b);
        sw{[2,3]} := sw{[3,2]};
        sh := ShallowCopy(b);
        sh{[2..n+1]} := sh{Concatenation([n+1],[2..n])};
        xr := ShallowCopy(b);
        xr[2] := xr[2]+xr[3];
        gens := [ sw, sh, xr ];
      fi;
      tr := ShallowCopy(b);
      tr[2] := tr[1]+tr[2];
      Add(gens, tr);
      return Group(List(gens,TransposedMat));
    end;
    
    Fix := function( g )
      local o, h, s, i, k;
      o := One(g);
      s := 2^(Size(g)-1);
      i := 1;
      h := g;
      while not IsOne(h) do
        k := NullspaceMat( h-o );
        if ForAny( k, v -> IsOne(v[1]) ) then
          s := s + 2^(Size(k)-1);
        fi;
        i := i+1;
        h := h*g;
      od;
      return 2^(s/i);
    end;
    
    f := function( n )
      local grp;
      grp := AG(n+1); # zero based
      return Sum( ConjugacyClasses(grp),
                  cc -> Size(cc)*Fix(Representative(cc)) ) / Order(grp);
    end;
    

    This is using somewhat advanced group theory (Burnside's lemma, twice), but no deep knowledge of the affine group. Still it is good enough to compute the 9th and 10th value (and more), which are:

    3743090921588631997590183810292071781042846067942809230428008257901850006463197026597863697259931801933484260185559925420090026
    479084991876032922658580043148767307553909132799686744495116429395794360341231625183693228836152593000430870733973647565874325953529940377811130038575926765372370447759627109606902989971984053705702177123141099357638755205930373003087364483930095902877678789627725054625735636
    

    Next sequence

    How does it work?

    There are 2^(2^n) Boolean functions of n variables. The affine group AG(n,2) acts on these functions by transforming the input. An affine transformation can permute the input, xor one input to another, and negate an input. (xor is addition in the field with two elements, negation is addition of one.)

    If a Boolean functions can be transformed in this way into an other, we consider them equivalent. The equivalence classes are called orbits. We want to know how many orbits there are.

    Burnside's lemma tells us that the number of orbits of an action of a group G on a set X equals the sum of the number of elements of X that are fixed by g (the sum is over each element g of G) divided by the order (size) of the group G.

    Since the affine group is big for moderate sizes of n, we want to avoid summing over all its elements. Conjugated elements fix the same number of elements of X, so we can sum instead over conjugacy classes and multiply with the size of the conjugacy class. There are not that much conjugacy classes, and GAP can compute them in reasonable time. (I wasn't sure about this when I started programming.) This is what the main function f does, using helper functions AG to create the affine group and Fix to determine the number of boolean functions that are fixed by an affine transformation.

    An affine transformation can be given by an invertible matrix A and an translation vector b, it maps x to Ax+b. This can be brought into the realm of linear algebra by embedding it into n+1 dimensional space. The affine transformation is represented by [[1, 0], [b, A]] (GAP wouldn't accept this). To see where the n dimensional x is mapped to, add a first component of 1, multiply with the matrix, and drop the first component of the result (which will be 1). You can think of adding an extra input that is always 1 and can not be changed by the transformation, but can be added (xor-ed) to other inputs. The AG function creates the affine group as matrix group using this representation.

    We create the affine group using four generators, the first three are only meaningful for n>1. The first swaps the first two inputs, the second cyclically shifts the inputs. (For n=2 they are the same, but that is no problem.) Together they generate all permutations of inputs. The third xors the second input to the first. By conjugation with a permutation, this gives all needed xor operations. Together, these three matrices generate the general (or special, that's the same in this case) linear group GL(n,2). The last generator negates the first input. Again, conjugation with a permutation gives the other negations, so all matrices together generate the affine group AG(n,2). You may have noted that my thinking, explaining and constructing has been in terms of right multiplying a column vector to a matrix. GAP however uses row vectors and left multiplication. Since I will use GAP's linear algebra functionality later, I compensate by transposing the generating matrices before construction the group.

    Now to the function Fix. We are given an affine transformation g and want to calculate the number of Boolean functions that it fixes. A function is fixed by g if it gives the same result to some input and to this input transformed by g (or g^2 etc). If an input can not be transformed into an other by a power of g, then the function may give different results for them. So the result is 2 to the number of classes of inputs that may get different results. We can get this number by another application of Burnside's lemma! This time the group is the cyclic group generated by g, and it is acting on the set of inputs of size 2^n. We really sum over all elements of the group now. The identity fixes all inputs, so we start the sum s with this number. Now assume we have a power h of g and want to know how many inputs it fixes. That means we want to know how many n+1 dimensional vectors with first component 1 are fixed by the matrix h, or how many are mapped to zero by h-1. So we use NullspaceMat to compute a basis of the kernel of h-1. If that contains no element with a 1 at the first component, then there are no solutions, otherwise there are half as many as the kernel size. In the end i contains the number of elements of the cyclic group, by which we divide the sum s as Burnside's lemma tells us.

    The last time I wrote similar code I used it to compute some numbers which I could use to find the series on OEIS and then find a better way to compute them there...

    I guess that the algorithm could be improved a lot without very complicated math. For example, I think it should be useful that the affine group is a semidirect product, but we give it to GAP as if it were any random matrix group.

    Now I hope this was useful or interesting for someone. I never know how much detail I should give in an explanation here.

    Christian Sievers

    Posted 2017-07-21T15:00:01.030

    Reputation: 6 366

    6

    226. Java 7, 4903 bytes, A000080

    Originally programmed by HyperNeutrino.

    import java.util.Arrays;
    import java.util.List;
    import java.util.ArrayList;
    
    abstract interface BooleanCombiner {
    	abstract boolean combine(boolean left, boolean right);
    }
    
    class Main {
    	static void print(boolean[][] matrix) {
    		for (boolean[] row : matrix) {
    			for (boolean e : row) {
    				System.out.print(e ? 1 : 0);
    				System.out.print(' ');
    			}
    			System.out.println();
    		}
    	}
    
    	static boolean[] combine(boolean[] left, boolean[] right, BooleanCombiner f) {
    		assert left.length == right.length;
    		boolean[] result = new boolean[left.length];
    		for (int i = 0; i < result.length; i++) result[i] = f.combine(left[i], right[i]);
    		return result;
    	}
    
    	static boolean none(boolean[] row) {
    		for (boolean element : row) if (element) return false;
    		return true;
    	}
    
    	static boolean all(boolean[] row) {
    		for (boolean element : row) if (!element) return false;
    		return true;
    	}
    
    	static int weight(boolean[] row) {
    		int weight = 0;
    		for (boolean element : row) if (element) weight++;
    		return weight;
    	}
    
    	static boolean[] DFS(boolean[][] matrix, int node, boolean[] visited) {
    		assert visited.length == matrix.length;
    		if (visited[node]) return visited;
    		visited[node] = true;
    		for (int neighbor = 0; neighbor < visited.length; ++neighbor) {
    			if (matrix[node][neighbor]) DFS(matrix, neighbor, visited);
    		}
    		return visited;
    	}
    
    	static boolean isConnected(boolean[][] matrix) {
    		return all(DFS(matrix, 0, new boolean[matrix.length]));
    	}
    
    	static int[][] triples(int length) {
    		int[][] triples = new int[length * ~-length * ~-~-length / 6][];
    		int index = 0;
    		for (int i = 0; i < length; i++) {
    			for (int j = i + 1; j < length; j++) {
    				for (int k = j + 1; k < length; k++) {
    					triples[index++] = new int[] { i, j, k };
    				}
    			}
    		} return triples;
    	}
    
    	static boolean isomorphic(boolean[][] a, boolean[][] b) {
    		int[] permutation = new int[a.length];
    		for (int i = 0; i < permutation.length; ++i) permutation[i] = i;
    		while (true) {
    			// check here
    			boolean maybe_valid = true;
    			for (int i = 0; i < permutation.length && maybe_valid; ++i) {
    				for (int j = 0; j < permutation.length; ++j) {
    					if (a[i][j] != b[permutation[i]][permutation[j]]) {
    						maybe_valid = false;
    						break;
    					}
    				}
    			}
    			if (maybe_valid) {
    				return true; // actually valid!
    			}
    			
    			// advance the permutation here. Implement C++'s std::next_permutation
    			int j = permutation.length - 1;
    			while (j != 0) {
    				if (permutation[j - 1] > permutation[j]) --j;
    				else break;
    			}
    			if (j == 0) break; // reached last permutation
    			// reverse [j, permutation.length) segment
    			for (int k = j, l = permutation.length - 1; k < l; ++k, --l) {
    				int tmp = permutation[k]; permutation[k] = permutation[l]; permutation[l] = tmp;
    			}
    			// find smallest element in [j, permutation.length) that is still larger than permutation[j-1]
    			int k = j; // sorry, meaningless variable name;
    			while (permutation[k] < permutation[j-1]) ++k;
    			int tmp = permutation[j-1]; permutation[j-1] = permutation[k]; permutation[k] = tmp;
    		};
    		return false;
    	}
    
    	static boolean[][] construct (int size, boolean[] mask, int[][] triples_table) {
    		assert triples_table.length == mask.length;
    		boolean[][] matrix = new boolean[size][size];
    		for (int index = 0; index < mask.length; ++index) {
    			if (mask[index]) {
    				int[] triple = triples_table[index];
    				int i = triple[0], j = triple[1], k = triple[2];
    				matrix[i][j] = matrix[j][i] = matrix[i][k] = matrix[k][i] = matrix[j][k] = matrix[k][j] = true;
    			}
    		}
    		return matrix;
    	}
    
    	
    	static List<boolean[][]> calculate (int size) {
    		List<boolean[][]> matrices = new ArrayList<>();
    		int[][] triples_table = triples(size);
    		boolean[] mask = new boolean[triples_table.length];
    		while (true) {
    			boolean[][] matrix = construct(size, mask, triples_table);
    			process_matrix:
    			if (isConnected(matrix)) {
    				// check if matrix is isomorphic to any existing matrix
    				for (boolean[][] existing_matrix : matrices) {
    					if (isomorphic(matrix, existing_matrix)) break process_matrix;
    				}
    				// check if the matrix is minimal
    				for (int delete_triple = 0; delete_triple < mask.length; ++delete_triple) {
    					if (! mask[delete_triple]) continue;
    					mask[delete_triple] = false; // temporarily set to false
    					if (isConnected(construct(size, mask, triples_table))) {
    						// it is not minimal
    						mask[delete_triple] = true; // remember to restore it ... 
    						break process_matrix;
    					}
    					mask[delete_triple] = true; // ... in any condition
    				}
    				/* it is both minimal and not counted now, */ matrices.add(matrix);
    			}
    			
    			int i = mask.length - 1;
    			while (i >= 0 && mask[i]) mask[i--] = false;
    			if (i == -1) return matrices; // considered all <mask> possible.
    			mask[i] = true;
    		}
    	}
    	
    	public static void main(String[] args) {
    		System.out.println(calculate(Integer.parseInt(args[0]) + 3).size());
    	}
    }
    

    Try it online!

    Next sequence.

    user202729

    Posted 2017-07-21T15:00:01.030

    Reputation: 14 620

    Nice! @HyperNeutrino Did you find out what was the problem with the lean fish graph? – J. Sallé – 2017-10-18T14:05:54.823

    @J.Salle user202729 pointed it out to me; my isValid function didn't work because one of the cycles didn't have any vertices with order 2 because rather than disconnecting a single node, it split the graph. Credit goes to them, not me :) – HyperNeutrino – 2017-10-18T14:08:05.810

    abstract interface makes me sad... and now it's immortalized here since you aren't allowed to change it... – Socratic Phoenix – 2017-10-18T14:09:17.073

    Very nice. Next sequence looks easy enough even I might give it a try hahahah – J. Sallé – 2017-10-18T14:09:49.410

    1@SocraticPhoenix Originally programmed by HyperNeutrino. – user202729 – 2017-10-18T14:11:08.090

    1I'm confused about how, for the next sequence, 0 is a sum of any NONZERO 10th powers, unless I'm totally misreading it... – Giuseppe – 2017-10-18T14:13:26.237

    @Giuseppe Sum of 0 numbers in the set {1,2^10,3^10,...} is 0. The sequence said "at most 8 numbers". – user202729 – 2017-10-18T14:15:04.077

    Is the next sequence infinite? – Stephen – 2017-10-18T15:28:01.120

    @Stephen Yes. (well you need to read the sequence details if you want to implement it anyway, so why asking?) – user202729 – 2017-10-18T15:38:39.500

    6

    233. Hexagony, 141 bytes, A000332

        ? } = & \
       . . @ } ( .
      ( . . . _ . .
     . } . . 2 & . .
    . . * . 4 . { . .
     . . ' \ ' \ * . 
      . . ( . : . "
       . . { ! . .
        . . * . .
    

    Try it online!

    Next sequence!

    Note: due to problems with remembering to check whether a bytecount was used before (to be clear: in this case, not by me), this answer has changed 2 times in total, with each of the 3 programs having a full explanation. Check the revision history if you want.

    Explanation

    There's practically no control flow here. The code has one, constant execution path. It starts at the top left corner going right, gets reflected by multiple mirrors, wraps around a few times and passes through unrelated instructions after printing the result to end at the @ (I'm sorry) in the second row. For reference, here's a picture of the execution path, with a color change every time it hits a mirror. I also changed the color during a long stretch of instructions on the bottom left to make the wraparound clear.

    control flow diagram

    The code operates on 3 memory edges: let's call the one we start on A, the one to the left of it - L, and the one to the right of A - R. binomial(n, 4) can be evaluated with the formula n(n-1)(n-2)(n-3)/24, which is imminent if you think about it, and a similar one could be created for every constant value of the bottom argument. Let's consider the linear path the code takes:

    ?}=&(}=*{('*}("*{&24':!*=@
    ?                          Input integer. A = n
     }=&                       Move to the R edge and copy the value of n. R = n
        (                      Decrement. R = n - 1
         }=                    Move to the L edge.
           *                   L = A * R = n(n-1)
            {(                 Move to the R edge and decrement. R = n - 2
              '                Equivalent to ={=, move to the A edge.
               *               A = L * R = n(n-1)(n-2)
                }(             Move to the R edge and decrement. R = n - 3
                  "            Equivalent to =}=, move to the L edge.
                   *           L = A * R = n(n-1)(n-2)(n-3)
                    {&         Move to the R edge and set it to 0 using an edge that
                               hasn't been used before
                      24       Set the value of the R edge to 24. A digit in Hexagony
                               multiplies the edge value by 10 and adds its value to
                               it, which allows chaining them to create multi-digit
                               numbers, but requires the value of the edge to be 0
                        '      Equivalent to ={=, move to the A edge
                         :     A = L / R = n(n-1)(n-2)(n-3)/24 = a(n)
                          !    Print the result
                           *=  Instructions that happen to be in the execution path
                               and not disrupt it
                             @ End the program
    

    NieDzejkob

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 630

    6

    241. Trefunge-98 (PyFunge), 230 bytes, A000256

           v   >51>R1-:v>RRO:8*'+-*'9+*O3*9-2Pv
    >4      (&:|  \    >|v   ;>v;      <:R: -4<
    ^"FRTH"<@.1<  +  @.$<>R1-:|>\1-RO*\^
     ^ useful     1     v\0\$$< A000256
     library      \     >:1-:v >\:v
    O:8*'3-*'Q+/4/^     ^    _$^ *_$/7*\-
    

    Try it online!

    Next sequence!

    To understand this monstrosity, you first need a quick primer on Funge:

    • All variants of Funge are primarily stack based.
    • The stack can only contain numbers.
    • Befunge is a 2D language. While Trefunge is 3D, this code would work fine without the third dimension.
    • <^>v are used to redirect execution exactly like you would expect.
    • +-*/ do addition, subtraction, multiplication and division.
    • Digits push the corresponding number on the stack
    • The instruction pointer starts in the upper left corner pointing right.
    • Space is a no-op
    • " toggles stringmode. In stringmode, the ASCII code of each character is pushed on the stack
           v
    >4      (
    ^"FRTH"<

    You can see that immediately the execution is redirected on the string "FRTH". Because the execution goes right to left, 70 (F) is on the top of the stack. Then the number 4 is pushed and ( loads the fingerprint.

    Fingerprints are similar to libraries from other languages, except they are not created in Funge, which would make them more of a language extension. Fingerprints change the semantics of the commands A through Z, which normally all act like r (reflect). You can load fingerprints using (, which more or less pops the number of characters the fingerprint code takes and then pops the characters themselves.

    The FRTH fingerprint stands for FORTH, because it includes some useful stack manipulation primitives that originated from FORTH. This program uses the following of them:

    • R - rotate. (... a b c) -> (... b c a)
    • O - over. (... a b) -> (... a b a). Equivalent to 1P.
    • P - push. Takes a number n and copies the element buried n elements deep to the top. For example, 2P would change the stack like this:
      (... a b c) -> (... a b c a)
       >51>R1-
    (&:|  \
    @.1<  +

    After loading the fingerprint, & inputs a number and pushes it on the stack. : is used to duplicate it because | consumes one copy. | is the vertical conditional. If the number it consumed is zero, it's equivalent to v. Otherwise, it acts like ^.

    It is used here because the input of zero needs to be a special case - the loop counter would immediately go negative making the loop infinite and OEIS claims that the formula only works for n > 4. If zero is passed, 1 is pushed, . is used to output it and @ ends the program.

    You can also see here the beginning of the main loop of the program. The loop begins with R1- and ends with +\. The stack at the beginning of each iteration looks like this: i n a(n-1). i-1 is the number of repetitions the program will do, since it is decremented and compared at the beginning of the loop. n is the index in the sequence of the value we will be computing, while a(n-1) is the previous value. We implement this formula from the OEIS:

    a(n) = (1/4)*(7*binomial(3*n-9, n-4)-(8*n^2-43*n+57)*a(n-1)) / (8*n^2-51*n+81)
    

    Let's tackle the main loop itself:

    R1-:v>RRO:
        >|
      @.$<
    

    R brings i to the top. Funge doesn't have a decrement instruction, so we subtract 1 explicitly with -. We duplicate the new i with : for testing with |. If we're finished, we will hit the < and execute the following linear code:

    $.@    The stack is now: n a(n-1) i
    $      Discard i
     .     Output a(n-1)
      @    Exit.
    

    In most cases, however, | will act like ^, which will make the interpreter execute this long stretch of linear code (ignoring the line wrap):

    RRO:8*'+-*'9+*O3*9-2P4- The stack is now: n a(n-1) i
    RR                      Bury i where it belongs. Stack: i n a(n-1)
      O:                    Copy n to the top and duplicate. Stack: i n a(n-1) n n
        8*                  Multiply by 8. Stack: i n a(n-1) n 8n
          '+                Use the ASCII value of + to push 43 on the stack
            -               Subtract 43. Stack: i n a(n-1) n 8n-43
             *              Multiply. Stack: i n a(n-1) 8n^2-43n
              '9+           Add 57. Stack: i n a(n-1) 8n^2-43n+57
                 *          Multiply. Stack: i n (8n^2 - 43n + 57)*a(n-1)
                  O         Copy n to the top. Stack: i n (...)*a(n-1) n
                   3*9-     Compute 3n-9. Stack: i n (...)*a(n-1) 3n-9
                       2P4- Copy n to the top, compute n-4.
                            Stack: i n (...)*a(n-1) 3n-9 n-4. Notice how the top two
                            elements are the arguments for the binomial.
    

    We will now compute the binomial(n, k) using the following algorithm which I've come up with myself a few sequences before, but it's probably not anything innovative, since it is obvious when you look at the formula. You can also see it in my Boo answer above.

    • Multiply k numbers starting with n, going down
    • Divide by the factorial of k

    Let's only consider the very top of the stack when considering the algorithm.

    v   ;>v;      <:R:
    >R1-:|>\1-RO*\^
      \$$<
    

    This is the part before computing the factorial. After :R:, the ; is a bridge, which skips the >v part.

       v   ;>v;      <
    :R:>R1-:|>\1-RO*\^ Stack: n k
    :                  Duplicate. Stack: n k k
     R                 Rotate. Stack: k k n
      :                Duplicate. Stack: k k n n. The bottommost k is used later.
                       The other k is the loop counter. The topmost n is the number
                       we're multiplying by, while the other n is the partial product.
       >               The loop starts here. Let's rename the variables and ignore
                       the bottom k. Stack: k product n
        R1-            Decrement k. Stack: product n k-1
           :|>         Exit the loop if k-1 is zero. Uses the >v part that is skipped
                       using a bridge
              \1-      Bring n to the top and decrement. Stack: product k-1 n-1
                 R     Rotate. Stack: k-1 n-1 product
                  O    Over. Stack: k-1 n-1 product n-1
                   *   Multiply - extend the partial product.
                       Stack: k-1 n-1 (product)(n-1)
                    \  Swap, restoring the stack to the order from the start of the
                       loop. Stack: k-1 (product)(n-1) n-1
                     ^ Jump to the beginning.
    

    When the loop ends, we execute this:

    $$\                Stack: k p n-k 0
    $$                 Discard the top two elements, we only need the product
      \                Bring k to the top for computing the factorial. Stack: p k
    

    Let's consider the factorial code:

    v\0
    >:1-:v >\:v
    ^    _$^ *_$
    

    It consists of two loops. Let's consider the factorial of 4.

    0\>:1-:v_$ Stack: 4
    0\         Push the marker used in the second loop, swap. Stack: 0 4
      >        The loop starts here
       :1-     Duplicate and decrement. Stack: 0 4 3
          :v_  Duplicate for the comparsion, loop if not 0.
      >        Consider the loop again, with stack: 0 4 3 2 1
       :1-     Duplicate and decrement. Stack: 0 4 3 2 1 0
          :v_  Duplicate for the comparsion and exit the loop.
             $ Discard the top 0. Stack: 0 4 3 2 1
    

    The second loop multiplies the numbers together, while 0 is marking the end.

    >\:v_*  Stack: 0 4 3 2 1
    >       The loop starts here
     \      Swap. Stack: 0 4 3 1 2
      :v_   If the top element is 0, end the loop
         *  Multiply. Stack: 0 4 3 2
    >       Consider the loop again, with stack: 0 4 6
     \      Swap. Stack: 0 6 4
      :v_   (doesn't end the loop)
         *  Multiply. Stack: 0 24
    >       Finally, let's see how the loop terminates.
     \      Swap. Stack: 24 0
      :v_   Ends the loop. Stack: 24 0
    

    Let's finish the main loop, since it now consists of only linear code. It is useful to see the formula while following the code:

    a(n) = (1/4)*(7*binomial(3*n-9, n-4)-(8*n^2-43*n+57)*a(n-1)) / (8*n^2-51*n+81)
    

    Let's mark the numerator x and the denominator y, to simplify the description.

    a(n) = (1/4)*x/y
    

    Keep it mind that when the instruction pointer hits the edge of the Fungespace, it wraps around.

    $/7*\-O:8*'3-*'Q+/4/\1+\ Stack: i-1 n (...)*a(n-1) p k! 0
    $                        Discard the 0 marker from the factorial loop.
     /                       Divide to compute the binomial.
                             Stack: i-1 n (...)*a(n-1) binomial(3n-9 n-4)
      7*                     Multiply by 7. Stack: i-1 n (...)*a(n-1) 7*binomial
        \-                   Swap and subtract. Stack: i-1 n 7*binomial-(...)*a(n-1)
          O:                 Over, duplicate. Stack: i-1 n x n n
            8*               Multiply by 8. Stack: i-1 n x n 8n
              '3-            Subtract 51. Stack: i-1 n x n 8n-51
                 *           Multiply. Stack: i-1 n x 8n^2-51n
                  'Q+        Add 81. Stack i-1 n x 8n^2-51n+81
                     /       Divide. Stack: i-1 n x/y
                      4/     Divide by 4. Stack: i-1 n a(n)
                        \1+\ Increment n. Stack: i-1 n+1 a(n), or as the next
                             iteration would call it: i n a(n-1)
    

    NieDzejkob

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 630

    "nominator"? Should it be "numerator"? – user202729 – 2017-10-28T12:29:16.843

    @user202729 You are right. That's what you get when you don't learn math in English... :P – NieDzejkob – 2017-10-28T12:30:01.247

    Also can you add an explanation what is the sequence? – user202729 – 2017-10-28T12:58:03.613

    @user202729 I totally would if my current understanding of this sequence aligned with the values given by the OEIS. – NieDzejkob – 2017-10-28T13:40:11.453

    6

    253. MIT/GNU Scheme, 1516 bytes, A000251

    (define (add f g)
      (stream-map + f g) )
    
    (define (sub f g)
      (stream-map - f g) )
    
    (define (scale c f)
      (stream-map (lambda (v) (* c v)) f) )
    
    (define (adddiag sf)
      (let ((f0 (stream-first sf)))
        (cons-stream (stream-first f0)
                     (add (stream-rest f0) (adddiag (stream-rest sf))) ) ) )
    
    (define (mult f g)
      (adddiag (stream-map (lambda (v) (scale v g)) f)) )
    
    (define (prependzeros n f)
      (if (= 0 n) f (cons-stream 0 (prependzeros (-1+ n) f))) )
    
    (define (intersperse f n)
      (cons-stream (stream-first f)
                   (prependzeros n (intersperse (stream-rest f) n)) ) )
    
    (define (iterate fun init)
      (cons-stream init (iterate fun (fun init))) )
    
    (define (from n)
      (iterate 1+ n) )
    
    (define (scanl fun init s)
      (cons-stream init (scanl fun (fun init (stream-first s)) (stream-rest s))) )
    
    (define (expx f)
      (cons-stream 1
                   (adddiag (stream-map (lambda (s g) (scale (/ 1 s) g))
                                        (scanl * 1 (from 2))
                                        (iterate (lambda (g) (mult f g)) f) )) ) )
    
    (define (eu f)
      (expx (adddiag (stream-map (lambda (n) (scale (/ 1 n)
                                                    (intersperse f (-1+ n)) ))
                                 (from 1) ))) )
    
    
    (define ones
      (cons-stream 1 ones) )
    
    (define s
      (iterate eu ones) )
    
    (define r
      (stream-map sub (stream-rest s) s) )
    
    (define t6
      (sub (stream-ref r 1)
           (cons-stream 0 (mult (stream-first r) (stream-ref s 1))) ) )
    
    (define (f n)
      (stream-ref t6 (+ 6 n)) )
    

    Next sequence

    Use like this:

    $ scheme -load t6.scm
    MIT/GNU Scheme running under GNU/Linux
    [...]
    1 ]=> (f 49)
    
    ;Value: 1110994054004
    

    This answer is based on generating functions given in J. Riordan's paper The Enumeration of Trees by Hight and Diameter mentioned at the OEIS entry of the sequence. Equation numbers will refer to this paper.

    First, let s_h(x) be the counting generation function of rooted trees with height at most h by number of nodes, i.e. the coefficient of x^n will give the number of such trees with n nodes. All our generating functions will count by number of nodes in this way.

    We can get one such function from the previous by eq. (1):

    s_{h+1}(x)=x*exp(s_h(x)+s_h(x^2)/2+s_h(x^3)/3+...)

    This is a shifted Euler transformation, which makes sense: the transformation takes a series a_0=0, a_1, a_2... where the a_i tell in how many ways you can get a thing of size/weight/whatever i and gives a series b_0=1, b_1, b_2... where b_j tells in how many ways you can get a multiset of such things with total size/weight/... of j. A rooted tree of height at most h+1 corresponds to a bunch (multiset) of rooted trees of hight at most h, with all their roots connected to a new root, which explains the shifting (multiplication with x).

    My function eu (I'm reusing a big part of my solution No. 122) to compute the Euler transformation takes a sequence starting with a_1 and returns a sequence starting with b_0. If we keep our sequences starting with the coefficient of x, we just need to iterate the eu function and the shifting is automatic. The code defines s as infinite stream of s_h (the highest we need is s_3, but it is still simpler like this), where we could start with s_0(x)=x, or even s_{-1}(x)=0, but we start with s_1(x)=x/(1-x)=x+x^2+x^3+.... BTW, s_2 is almost the generating function for the partition numbers, just shifted.

    Next, let r_h(x) be the generating function for rooted trees with height exactly h. Obviously, we have r_h(x)=s_h(x)-s_{h-1}(x). The code defines r to be the stream of these r_h, starting with r_2.

    Finally, let t_d(x) be the generating function for trees of diameter d. For even d, thos can be expressed by eq. (6a) as

    t_{2d}(x) = r_d(x) - r_{d-1}(x)*s_{d_1}(x)

    The paper derives this formula algebraically from some other, but it can also be seen directly by comparing coefficients. For fixed d and n it claims that there are as many rooted trees of height d and with n nodes, as there are elements in the disjoint union of (1) trees of diameter 2d and with n nodes, and (2) pairs of rooted trees of height d-1 and of rooted trees of height at most d-1, where the pair has a total number of n nodes. This can be shown by a bijection: given a rooted tree of height d, remove the root and look at the multiset of subtrees you get. At least one of them has height d-1. If there are more than that, then the original tree was of diameter 2d. So forget the root and map it to this tree. Otherwise, form a pair with the one subtree of size d-1, and a tree of size at most d-1 that is created by rejoining the other subtrees with a new root. (Details are left as an exercise to the reader...)

    The code directly defines t_6 according to this formula. Since we kept the generating functions starting with x while the multiplication function expects series starting with the constant term, the result must be interpreted as starting with the coefficient of x^2. To compensate, we put a 0 in front of it.

    And if you ever need to enumerate trees with odd diameter, their generating function is given by eq. (5) as

    t_{2d+1}(x) = (r_d^2(x)+r_d(x^2))/2

    Christian Sievers

    Posted 2017-07-21T15:00:01.030

    Reputation: 6 366

    Cutting it a little close, don't you think? – KSmarts – 2017-11-20T14:09:22.470

    1Since just using some formula isn't very well recieved, I wanted to give time for other solutions. (But now I mostly understand what I do...) And I had to look for a free language, and initially didn't want to use scheme again. – Christian Sievers – 2017-11-20T14:31:37.120

    There are reasonable hints towards eq. 5 in OEIS, but nothing towards eq. 6a. Did you find an electronic copy of the paper or did you have to go to a library? Either way, well done. – Peter Taylor – 2017-11-23T13:52:14.570

    @PeterTaylor I went to a library. – Christian Sievers – 2017-11-23T14:02:02.967

    6

    259. Hy, 1333 bytes, A000329

    (setv precision 80)
    
    (import decimal)
    
    (setv ctx (.getcontext decimal))
    (setv ctx.prec precision)
    (setv Decimal decimal.Decimal)
    
    (defn approx-pi [series-terms]
      (sum
        (list-comp
          (/ (- (/ 4 (Decimal (+ 1 (* 8 n))))
                (/ 2 (Decimal (+ 4 (* 8 n))))
                (/ 1 (Decimal (+ 5 (* 8 n))))
                (/ 1 (Decimal (+ 6 (* 8 n)))))
             (** 16 n))
          (n (range series-terms)))))
    
    (setv pi (approx-pi precision))
    
    (defn cos [x series-terms]
      (cond
        [(>= x (* 2 pi))
         (cos (- x (* 2 pi)) series-terms)]
        [(neg? x)
         (cos (- x) series-terms)]
        [(>= x (/ (* 3 pi) 2))
         (cos (- (* 2 pi) x) series-terms)]
        [(>= x pi)
         (- (cos (- x pi) series-terms))]
        [(>= x (/ pi 2))
         (- (cos (- pi x) series-terms))]
        [True
         (sum
           (list-comp
             (*
               (if (even? n) 1 -1)
               (reduce *
                 (list-comp
                   (/ x (inc i))
                   (i (range (* 2 n))))
                 1))
             (n (range series-terms))))]))
    
    (defn tan [x series-terms]
      (/
        (cos (- x (/ pi 2)) series-terms)
        (cos x series-terms)))
    
    (setv bvalues {0 (Decimal 1)})
    
    (defn b [n]
      (try
        (get bvalues n)
        (except [KeyError]
          (do
            (assoc bvalues n (tan (b (dec n)) precision))
            (get bvalues n)))))
    
    (defn A000329 [n]
      (int (round (b n))))
    

    Next sequence

    The difficulty with this sequence is that it's an iterated function, which means that small floating-point errors are magnified as n increases. So we need very accurate numbers. Enter Python's decimal module, which supports arbitrary-precision decimal arithmetic!

    Because the decimal module doesn't seem to have trig functions, I reimplemented pi and cos. To calculate pi, I used the series approximation here, which converged pretty fast. For cosine, I used the MacLaurin series. Then I implemented tan as sine over cosine, with sin(x) = cos(x - pi/2).

    Finally, I used the definition of A000329 from OEIS: "Nearest integer to b(n), where b(n) = tan(b(n-1)), b(0) = 1." I memoized the definition of b--not really necessary, but speeds up the generation of tables of values. Some experimentation showed that a decimal precision of 80 was sufficient to correctly compute n = 1000.

    Now, of course, Python itself has already been used in this challenge, so the next task was to find a Python-based language that hadn't been used yet. I found Hy, which is basically Python with Lisp syntax. One translation, new Ubuntu VM, and language installation later, and voilà!

    DLosc

    Posted 2017-07-21T15:00:01.030

    Reputation: 21 213

    5

    Erik the Outgolfer

    Posted 2017-07-21T15:00:01.030

    Reputation: 38 134

    2Noo, Kolakoski.... – Mr. Xcoder – 2017-07-21T15:24:17.680

    @Mr.Xcoder well that's why it's called a "challenge" – Erik the Outgolfer – 2017-07-21T15:24:55.110

    6I deleted this because I don't want to use Jelly just yet; so much for that – Stephen – 2017-07-21T15:25:34.890

    And I even had f(x){return!x*2;} in ANSI C... – LegionMammal978 – 2017-07-21T15:26:21.967

    5

    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}
    

    Post Rock Garf Hunter

    Posted 2017-07-21T15:00:01.030

    Reputation: 55 382

    @cairdcoinheringaahing I don't know. Is that not allowed? – Post Rock Garf Hunter – 2017-07-21T15:46:46.793

    no its fine. I just thought that it could help the next answerer – caird coinheringaahing – 2017-07-21T15:51:29.173

    5

    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

    Leaky Nun

    Posted 2017-07-21T15:00:01.030

    Reputation: 45 011

    5

    19. Curry, 45 bytes, A000037

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

    Try it online

    Next sequence

    BlackCap

    Posted 2017-07-21T15:00:01.030

    Reputation: 3 576

    ninja'd by 37 seconds >.< – HyperNeutrino – 2017-07-21T20:12:47.277

    but you were ninja'd by 23 seconds rip – HyperNeutrino – 2017-07-21T20:13:37.140

    5

    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

    Stephen

    Posted 2017-07-21T15:00:01.030

    Reputation: 12 293

    5

    25. eta, 183 bytes, A000033

    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

    BlackCap

    Posted 2017-07-21T15:00:01.030

    Reputation: 3 576

    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 – 2017-07-22T00:09:47.623

    @HyperNeutrino My FiM++ answer was posted 22:28, this was posted 23:29 – BlackCap – 2017-07-22T00:13:49.027

    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 – 2017-07-22T00:15:01.690

    Reading through all answers here, and wondering how many essentially-haskell answers are coming still :p – tomsmeding – 2017-07-23T08:03:20.103

    @tomsmeding I still have idris and elm left – BlackCap – 2017-07-23T08:28:53.637

    5

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

    ETHproductions

    Posted 2017-07-21T15:00:01.030

    Reputation: 47 880

    Please put a "29." in your header. I think you're confusing the Stack Snippet. – Silvio Mayolo – 2017-07-22T01:00:44.943

    @SilvioMayolo Ah sorry. This is my first time since #3, so I've already forgotten how to answer :P – ETHproductions – 2017-07-22T01:01:31.987

    4@SilvioMayolo he made the stack snippet :P – Stephen – 2017-07-22T02:37:00.647

    5

    35. dc, 67 bytes, A000168

    ?sw[1[li*li1-dsi0<o]soli0<o]se3lw^2*lw2*silex*lwsilexlw2+silex*/p0P
    

    Try it online!

    Next Sequence

    R. Kap

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 730

    165 is already used – Leaky Nun – 2017-07-22T06:00:30.183

    @LeakyNun Fixed – R. Kap – 2017-07-22T06:03:54.157

    5

    36. J, 124 bytes, A000067

    squares =: *:@i.@>:@<.@%:
    filter =: ] #~ [ >: ]
    f =: [: <: (2^]) +/@:>: [: ~.@,/ (2^<:@]) (] +/ 2 * filter) [: squares (2^])
    

    Try it online!

    Next sequence

    Leaky Nun

    Posted 2017-07-21T15:00:01.030

    Reputation: 45 011

    Please make the next sequence in 6 bytes lol – Leaky Nun – 2017-07-22T06:38:16.240

    5

    37. 05AB1E, 6 bytes, A000124

    The courtesy of Leaky Nun.

    D>*2÷>
    

    Try it online!

    Next Sequence

    Mr. Xcoder

    Posted 2017-07-21T15:00:01.030

    Reputation: 39 774

    5

    alephalpha

    Posted 2017-07-21T15:00:01.030

    Reputation: 23 988

    5

    41. PHP, 503 bytes, A003416

    function f ($n) {
      $i=12495; $cnt=0; $used =[];
    
      while (true) {
        $i++;
        $ns = [];
        $v = $i;
        $sm = $i;
    
        while (!in_array($v, $ns)) {
          $ns[] = $v;
          $s = 0;
    
          for ($k=1; $k<=$v/2; $k++)
            if ($v % $k == 0) $s += $k;
    
          $v = $s;
          if ($s == 1) break;
          $sm = min($sm, $v);
        }
    
        if ($v < 2) continue;
        if (in_array($sm, $used)) continue;
        if ($cnt == $n) return $sm;
        $cnt++;
    
        for ($i=0; $i < count($ns); $i++) $used[] = $ns[$i];
      }
    }
    

    Try it online!

    Next sequence

    BlackCap

    Posted 2017-07-21T15:00:01.030

    Reputation: 3 576

    5

    42. Cheddar, 28 bytes, A000503

    n->(tan(n)|0)-(tan(n)<0?1:0)
    

    Try it online!

    Next sequence

    Leaky Nun

    Posted 2017-07-21T15:00:01.030

    Reputation: 45 011

    5

    43. Swift 4, 651 bytes, A000028

    func bit_sum_parity(n: Int) -> Int {
        var res = 0;
        var test = n;
        while test > 0 {
            res ^= test%2;
            test /= 2;
        }
        return res;
    }
    
    func A000028(n: Int) -> Int {
        var res = 1;
        var iter = n;
        while iter > 0 {
            var clone = res;
            var p = 2;
            var parity = 0;
            while clone > 1 {
                var count = 0;
                while clone % p == 0 {
                    clone /= p;
                    count += 1;
                }
                parity ^= bit_sum_parity(n: count);
                p += 1;
            }
            if parity == 1 {
                iter -= 1;
            }
            res += 1;
        }
        return res-1;
    }
    

    Try it online!

    Next Sequence - A000651

    Mr. Xcoder

    Posted 2017-07-21T15:00:01.030

    Reputation: 39 774

    5

    44. Maxima, 94 bytes, A000651

    f(n):=sum((2*k)!/k!/(k+1)!,k,1,n)+sum((2*binomial(n+k-1,k)-binomial(n+k,k))*f(n-1-k),k,0,n-2);
    

    Try it online!

    Next sequence

    alephalpha

    Posted 2017-07-21T15:00:01.030

    Reputation: 23 988

    1... and we're back to partition – Leaky Nun – 2017-07-22T12:53:01.430

    5

    59. Brachylog, 59 bytes, A000011

    ;2↔^gP~g⟦k;Pz+ᵐḃᵐbᵐ{↔;?T{{;1↔-}ᵐ}ᵐ,T{{~cĊ↔c}ᶠb}ᵐ{∋∋}ᶠo}ᵐ∋ᶜ¹
    

    Try it online!

    Next sequence

    Leaky Nun

    Posted 2017-07-21T15:00:01.030

    Reputation: 45 011

    5

    72. SML, 252 bytes, A000401

    fun A000401 x =
        let fun helper x y z =
            if z mod 4 = 0 then helper x y (z div 4)
            else if z mod 16 = 14 then helper x (y + 1) (y + 1)
            else if x = 0 then y
            else helper (x - 1) (y + 1) (y + 1)
        in helper x 0 1
        end
    

    Online demo

    (Note: those blocks which look like four spaces each are really tabs. I forgot about StackExchange forcing tabs into spaces, and now that I've posted the next sequence it's a bit late to change. If anyone is really fussed then they can be changed to use a single space for indentation).

    Next sequence

    Dissection

    This uses the characterisation given in Dickson's History of the Theory of Numbers:

    These are the numbers not of the form 4^k*(16*n + 14)

    I could have defined one helper function to test for numbers not in the sequence and another to find the xth number which passes the test, but I think it's more in the spirit of PPCG to use a single helper function with two accumulators. x is the number we still have to discard; y is the number currently under consideration; z is y divided by some power of 4.

    There is a small hack in calling it as helper x 0 1: if I called it as helper x 0 0 then there would be an infinite loop because 0 is divisible by 4 yielding 0.

    Peter Taylor

    Posted 2017-07-21T15:00:01.030

    Reputation: 41 901

    Good to see that you've decided to participate again! – caird coinheringaahing – 2017-07-23T21:25:02.937

    I was a little nervous about leaving it on this sequence, but I saw the 4^k(16n + 14) note in the OEIS comments and knew that would be quite doable. – ETHproductions – 2017-07-24T02:28:10.577

    @ETHproductions, it would have been easy to do it directly too. In CJam I would have used the definition because it's easier to do a three-way Cartesian product and set union than to do the loop to remove powers of 4. – Peter Taylor – 2017-07-24T05:47:08.657

    5

    101. Fortress, 335 bytes, A000020

    relativelyPrime(a,b)=array[\ZZ32\]((a MIN b)-1).fill(fn(n)=>1) EQ array[\ZZ32\]((a MIN b)-1).fill(fn(n)=>if ((a MOD (n+2))+(b MOD (n+2))) NE 0 then 1 else 0 end)
    totient(n)= do
     S : ZZ32 = 0
     for i <- 1:n do
      S += if relativelyPrime(i,n) then 1 else 0 end
     end
     S
    end
    A000020(n) = do
     |\if n = 1 then 2 else totient(2^n-1)/n end/|
    end
    

    Next Sequence

    Direct download of Fortress

    If the language was equivalent to the specification at the time that FOrtress got axed, then this would probably be easy. But sadly, Fortress got the boot, and I'm stuck with this crap >_<.

    Zacharý

    Posted 2017-07-21T15:00:01.030

    Reputation: 5 710

    Link to the language? – pppery – 2017-08-11T22:18:44.897

    Dead. Very dead. There it is. – Zacharý – 2017-08-11T22:22:08.170

    5

    115. shortC, 273 bytes, A001560

    pa(m){Fm%2){T-1;}E{T1;}}
    pt(m){Ii,p[200],s,j,k,t,kk;p[0]=1;for(i=1;i<=m;i++){j=1;k=1;s=0;Wj>0){kk=k*k;j=i-(3*kk+k)/2;t=pa(k);if(j>=0){s=s-t*p[j];}j=i-(3*kk-k)/2;Fj>=0){s=s-t*p[j];}k=k+1;}p[i]= s;}Ts}
    AIi,c;scanf("%d",&c);Oi=0;i<131;i++){Fpt(i)%2==0)c--;Fc==1)break;}R"%d",i
    

    Next sequence and Try it online!

    It's surprisingly hard to calculate partitions in a language that doesn't have many math builtins. This could be more golfed, but it could also be a lot less golfed. :P

    MD XF

    Posted 2017-07-21T15:00:01.030

    Reputation: 11 605

    1Formula: ~ very helpful, I'm glad I can approximate it – Stephen – 2017-08-18T19:23:33.237

    @StepHen hey it's not as bad as answer 96 :P – MD XF – 2017-08-18T19:24:38.937

    It's not that hard to calculate partitions: you just need some kind of loop and addition. The number of partitions of n is the sum over 1 <= k <= n of the number of partitions of n into k parts, which has recurrence p(n, k) = p(n-1, k-1) + p(n-k, k). Alternatively the number of partitions of n into parts of at most k has recurrence q(n, k) = n == 0 ? 1 : sum(q(n - i*k, k-1), i = 0 to n/k). – Peter Taylor – 2017-08-18T20:10:40.987

    @PeterTaylor I wasn't very clear; I tried this in lots of languages that weren't built to deal with math before I resorted to shortC. – MD XF – 2017-08-18T20:20:18.460

    Hmm. Tackling the next sequence by formula rather than enumeration requires working with big rationals. – Peter Taylor – 2017-08-18T22:31:04.333

    @PeterTaylor hmm maybe that's why this is the only answer to this question with 0 votes... I could easily modify the bytecount. Should I? – MD XF – 2017-08-19T00:21:03.663

    1NO. That's a complete violation of the spirit of the game. – Peter Taylor – 2017-08-19T06:12:02.303

    5

    149. dash, 1993 bytes, A000173

    Important: this is a precaution in case the INTERCAL answer for #149 is disqualified, to avoid #148 ending the chain due to the week having expired. It is deliberately the same length in order to preserve following answers.

    succ () {
        # The successor is the sum of strictly smaller unitary divisors, where a
        # unitary divisor is a product of some subset of the maximal prime power divisors.
        # In other words, if we factor n as
        #   \prod_i p_i^{a_i}
        # then the successor should be
        #   \prod_i (p_i^{a_i} + 1) - n
        local n=$1
        local m=1
        factor $n | sed "s% %\n%g" | tail -n +2 | uniq -c |
            # Workaround for buggy read on my computer
            sed "s%^ *%%;s% %\n%" |
            while read x
            do
                read y
                z=1
                for i in $( seq $x )
                do
                    z=$(( z * y ))
                done
                m=$(( m * (z + 1) ))
                # echo here and take tail because scope problems mean that m loses its
                # value outside this pipeline
                echo $(( m - n ))
            done
    }
    
    inseq () {
        local n=$1
        # We detect rhos using the little-step big-step method. If at any point we hit a
        # value less than n, clearly n isn't the smallest element of a cycle
        local k=$( succ $n | tail -1 )
        # If we loop already, it's unitary-perfect
        if test $k -le $n ; then return 1 ; fi
    
        local m=$( succ $k | tail -1 )
        # Loop already => it's unitary-amicable
        if test $m -le $n ; then return 1 ; fi
    
        while true
        do
            # Advance k once
            k=$( succ $k | tail -1 )
            # Advance m twice
            m=$( succ $m | tail -1 )
            if test $m -eq $n ; then return 0 ; fi
            if test $m -lt $n -o $m -eq $k ; then return 1 ; fi
            m=$( succ $m | tail -1 )
            if test $m -eq $n ; then return 0 ; fi
            if test $m -lt $n -o $m -eq $k ; then return 1 ; fi
        done
    }
    
    idx=$1
    # Naive approach: test all values from 2 to see whether they're in the sequence
    # until we've found enough that are
    j=2
    while true
    do
        if inseq $j
        then
            if test $idx -eq 0
            then
                echo $j
                return 0
            fi
            idx=$(( idx - 1 ))
        fi
    
        j=$(( j + 1 ))
    done
    

    Online demo

    Next sequence

    Peter Taylor

    Posted 2017-07-21T15:00:01.030

    Reputation: 41 901

    I wonder how the snippet will react to that :P – NieDzejkob – 2017-09-15T16:35:14.970

    No, I don't have A000083. I don't have a slightest idea about what is happening. Go ahead and choose some saner next sequence ;) – NieDzejkob – 2017-09-17T07:38:05.793

    Uh, @PeterTaylor did you get a notification when I replied? – NieDzejkob – 2017-09-17T19:00:16.387

    1@PeterTaylor gogogo – Husnain Raza – 2017-09-18T17:20:29.500

    @cairdcoinheringaahing, I don't understand your request. On the basis of the discussion on meta, where no-one has provided any answer contrary to mine or downvoted it, it's the other 149 which should be deleted and this one remains necessary. – Peter Taylor – 2017-09-23T20:28:57.090

    @PeterTaylor ah, I thought the discussion on meta was settled, for whatever reason. Removing comment – caird coinheringaahing – 2017-09-23T20:30:07.283

    5

    231. Shakespeare Programming Language, 938 bytes, A000086

    The Beautiful Story of Solving Quadratic Equations.
    Theseus, the mathematician.
    Dogberry, his calculator.
    Page, to avoid mistakes caused by imperfect mental math.
    Mistress Page, to make Page feel less lonely.
    
         Act XLII: Introducing modulus arithmetic.
        Scene I: Dogberry as a motivational speaker.
    [Enter Dogberry and Page]
     Dogberry:
       Listen to your heart!
    [Exeunt]
    
       Scene II: Complex math without complex numbers.
    [Exeunt]
    [Enter Theseus and Dogberry]
     Theseus:
       You are the remainder of the quotient between the sum of a cat and
       the product of Mistress Page and the sum of Mistress Page and a
       Microsoft and Page. Are you as big as nothing?
     Dogberry:
       If so, you are the sum of yourself and a cat.
    [Exit Dogberry]
    [Enter Mistress Page]
     Theseus:
       You are the sum of yourself and an angel. Are you as trustworthy as
       Page? If not, let us return to Scene II.
     Mistress Page:
       If so, open your heart.
    [Exeunt]
    

    Try it online!

    Next sequence!

    It's suprisingly hard to introduce words that mean nothing in the statement, so I didn't. Yes, Microsoft has a meaning - in fact, it's a negative noun so it means -1.

    NieDzejkob

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 630

    Please note that the bytecount changed in the first 10 or so seconds. – NieDzejkob – 2017-10-20T15:11:47.913

    5

    244. UCBLogo, 1524 bytes, A000112

    to permutations :list
        if :list = [] [op [[]]]
        op map.se [
            map [[ls] fput ? :ls] permutations (remove ? :list)
        ] :list
    end
    
    to dfs :node
        repeat :N [
            if and
            (1 = item :node item repcount :matrix) 
            not(item repcount :visited) 
            [
                setitem repcount :visited "true
                dfs repcount
            ]
        ]
    end
    
    to tuples :items :n
        if :n = 1 [op map "list :items]
        op (crossmap "fput :items tuples :items :n-1)
    end
    
    to isomorphic :mat1 :mat2 ; they must both have size N*N
        foreach permutations iseq 1 :N [
            catch "failed [
                for [i 1 :N] [
                    for [j 1 :N] [
                        if (
                                (item      :i    item       :j    :mat1)  
                                item (item :i ?) item (item :j ?) :mat2
                        ) [throw "failed]
                    ]
                ]
                op "true
            ]
        ]
        op "false
    end
    
    to solve :N
        if :N = 0 [op 1]
    
        localmake "visited array :N
        localmake "matrices []
        local "valid
    
        foreach tuples (tuples [0 1] :N) :N [ [matrix]
            make "valid "true
            for [node 1 :N] [
                repeat :N [
                    setitem repcount :visited "false
                ]
                dfs :node
    
                if (item :node :visited) [
                    make "valid "false
                    throw "for.catchtag ; FMSLogo-specific way to break for loop
                    ; because Logo doesn't have Break command.
                ]
                repeat :N [
                    if and (item repcount :visited) (0 = item :node item repcount :matrix) [
                        make "valid "false
                        throw "for.catchtag
                    ]
                ]
            ]
    
            if :valid [
                catch "nextmatrix [
                    foreach :matrices [
                        if isomorphic :matrix ? [throw "nextmatrix]
                    ]
                    make "matrices fput :matrix :matrices
                ]
            ]
        ]
        op count :matrices
    end
           

    Next sequence.

    There are 7 spaces in the last line.

    You can try it online here. Just enter the program and append print solve 3 (for example) in the end.

    I choose UCBLogo for this sequence because I don't want to use FMSLogo, which I want to keep for a more geometry-related sequence.

    So, in the end I gave up and just post my bruteforce solution.

    This one takes a long time to calculate for just n=4. The MD5 I mentioned in the chat is for the version with some spaces at the end removed.


    Explanation:

    First, the program generates all possible N×N matrices tuples (tuples [0 1] :N) :N. Each matrix represent a directed graph with N vertices.

    For each matrix (store in variable matrix, it checks whether it represents a poset (Two vertices A and B has the edge A→B connected if and only if A<B) by: for each node, it runs a DFS from that node, and verify that it can't reach that node (there is no cycle in the graph), and there is an edge from the node to every reachable nodes (because < is transitive).

    After having checked that the matrix represents a valid poset, the program checks whether it is isomorphic to any existing poset, stored in the matrices variable. If it is not, the program put :matrix to the first of the variable :matrices (make "matrices fput :matrix :matrices).

    Then in the end the program output the number of elements of :matrices (op count :matrices).

    user202729

    Posted 2017-07-21T15:00:01.030

    Reputation: 14 620

    1I need to stop trying to write efficient code for these tougher sequences. Or at least, I need to start seriously attempting them before there's only a day left. – KSmarts – 2017-11-06T14:11:18.037

    You could avoid the poset check by observing that each poset can be obtained from the subset relations among n subsets of {1,...,n}. But I'm not sure if creating all these (which can be optimized) and turning them into the.matrix representation of the graph is easier... – Christian Sievers – 2017-11-06T15:56:52.413

    @ChristianSievers So there would be ${2^n} \choose n$ graphs which is still significantly less than $2^{n^2}$. May be faster. It is not necessary to turn it into matrix representation too, if there is a way to check isomorphism of those. (Is it possible to check isomorphism of posets in polynomial time? Not for general graph, I know.) – user202729 – 2017-11-07T01:02:12.517

    You can easily bring the number of relevant matrices down to $3^((n-1)(n-2)/2)$, and my approach with the mentioned optimizations to less than $2^same$. So that seems nice, but my main idea was just to try to simpify the algorithm. I don't know about the isomorphism check, but be careful: graph isomorphism is not known to be NP-complete (subgraph isomorphism is), but has unknown complexity in NP (I mixed that up once myself) – Christian Sievers – 2017-11-07T02:51:45.317

    @ChristianSievers I don't really understand. First, how can I get complexity $3^{(n-1)(n-2) \over 2}$? I find it not obvious. (BTW your LaTeX need curly bracket in necessary places) Second, how is it important that graph isomorphism is NP-unknown? I can just use the fastest-available known algorithm that I can implement. – user202729 – 2017-11-07T08:07:35.527

    Not total complexity, but number of matrices. My exponent was wrong, it should be $n(n-1)/2$. There are that many unordered pairs of different elements $i, j$ with $1<=i,j<n$, and they are either unrelated, or one is less than the other according to the poset. So for the matrix entries $M_{i,j}$ and $M_{j,i}$ there are only three possibilities altogether. Of course the status of graph isomorphism is not important here, one just should not think it is NP-complete when that's not known, as I did for a while. – Christian Sievers – 2017-11-07T12:19:16.707

    @ChristianSievers Thanks, understood. – user202729 – 2017-11-07T12:23:22.947

    And then you can assume that the elements are numbered according to a topological sort, so there are only two possibilities for each pair and the matrix is triangular. Now it is not too difficult to only construct matrices that represent posets. It's slightly easier to explain when the matrix describes $<=$, not $<$: For $i=1$ to $n$, let $M_{i,i}=1$ and for $j=i-1$ downto $1$, if $M_{j,i}=0$ we may componentwise "and" the $j$-th column to the $i$-th column. – Christian Sievers – 2017-11-07T12:56:03.963

    5

    254. Enlist, 98 bytes, A001516

    W F †  0r   ‡ ;@ ±@ ¹ ! :/ §€¹  Ė  ‡ 2* :2 :@ §/€   † ↕ ḥ1 ↕ ×J ḥ1 § † ↕ ḥ1 ↕ ×J ḥ1 §   ;0   S  §€
    

    Try it online!

    haha enlist can do a thing :D

    Next Sequence

    Explanation

    WF†0r‡;@±@¹!:/§€¹Ė‡2*:2:@§/€†↕ḥ1↕×Jḥ1§†↕ḥ1↕×Jḥ1§;0S§€  Main Link
    W                                                      wrap; x => [x]
     F                                                     flatten (WF is just for test suite purposes lol)
                                                        €  For each (this just returns the first `n` elements if the input is an integer)
      †                                                §   Execute a monadic bracketed chain on each (let's call the argument `z`)
       0r                                                  Range from 0 to `z`, inclusive
                   €                                       For each in the range
         ‡        §                                        Execute a dyadic bracketed chain on each (let's call the argument `n`)
          ;@                                               Append `n` to
            ±@¹                                            [z + n, z - n]
               !                                           Factorial (of each)
                :/                                         Reduce over division (this gives (z + n)! / (z - n)! / n! which is what we want as the coefficient)
                    ¹                                      Identity as right argument to prevent dyad-monad chaining
                     Ė                                     Enumerate 1-indexed
                               €                           For each enumerated element (let's call the argument [x, y])
                      ‡      §/€                           Reduce over dyadic function (gives `x $ y`)
                       2*                                  2 ^ x
                         :2                                / 2 (floored)
                           :@                              y / (floored)
                                                         (this is y / 2 ^ (x - 1))
                                †        §                 Monadic bracketed expression (derivative step)
                                 ↕                         Reverse
                                  ḥ1                       All but last 1 element
                                    ↕                      Reverse
                                     ×J                    Multiply each with its index
                                       ḥ1                  All but last 1 element
                                          †↕ḥ1↕×Jḥ1§       Derivative again
                                                    ;0     Append 0 (to prevent empty-sum errors)
                                                      S    Sum
    

    HyperNeutrino

    Posted 2017-07-21T15:00:01.030

    Reputation: 26 575

    For the second time. Well, that means Enlist can't be used again till 300th answer. – user202729 – 2017-11-20T14:16:30.000

    cough cough bytecount cough – NieDzejkob – 2017-11-20T14:18:34.940

    @user202729 oh well, enlist isn't that great for this challenge due to its current lack of functionality. By the time it gets functionality it will probably be in the 300s. – HyperNeutrino – 2017-11-20T14:22:08.783

    Shouldn't it return the n-th number instead of a list of all numbers up to n? Anyway, good job – NieDzejkob – 2017-11-20T14:48:04.207

    @NieDzejkob eh, technically yes. fine, I'll fix it – HyperNeutrino – 2017-11-20T14:49:20.613

    5

    277. 2sable, 104 bytes, A000188

    Ln¹%1‹Oquery: no rules about unnecessary text?
    Nearest available byte count is 104 so this code is on it
    

    Try it online!

    Next Sequence

    It didn't seem like there was a rule against unnecessary text but if I misinterpreted I will delete.

    Explanation

    Ln¹%1‹Oq     Only part of the code that gets evaluated
    L            [1...n] where n is the input
     n           square: [1,4,9,...n**2]
      ¹          push the input n
       %         mod: [1%n,4%n,...(n**2)%n]
        1        push 1
         ‹       less than 1: [1%n<1,4%n<1,...(n**2)%n<1]
          O      count the ones in the array
           q     terminate the program
    uery: no...  not evaluated
    

    Regarding the next sequence, I almost skipped it because it looks hard but then changed my mind. It seems like a high level language would be useful there. I've noticed there are no Maple answers so someone could try it in that. There is also Pyon which from this answer seems like it is essentially just Python so I don't know if we are counting it as a separate language. Fortran is also available for an answer but I don't know if many people use it and it is not so high level.

    dylnan

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 993

    1Unnecessary bytes are allowed (and sometimes forced), mostly because of byte restriction. – user202729 – 2017-12-08T02:40:42.513

    1[tag:hard]? No, this one is easy. – user202729 – 2017-12-08T06:34:22.453

    @user202729 good, I was worried a little – dylnan – 2017-12-08T13:07:23.093

    For those working on the next one, you may want to look at Donald Knuth's POLYNUM and POLYSLAVE programs.

    – KSmarts – 2017-12-08T14:54:18.510

    BTW Pyon is a superset of Python, kind of like Coconut. Most Python code works in Pyon, and if there's code that doesn't, then it's a bug with Pyon. – HyperNeutrino – 2017-12-11T14:43:36.437

    5

    280. Axiom, 947 bytes, A002852

    artanh:(Float) -> Float
    artanh(x) == 
        y := x 
        k := 1
        for k in 1..precision() repeat
            z := x^(2*k+1) / (2 * k + 1)
            y := z + y
        return y
    
    ln2:() -> Float
    ln2() == artanh(0.5) + artanh(1.0 / 7)
    
    gamma:(NonNegativeInteger) -> Float
    gamma(e) ==
        precision(2 ^ e + 100)
        n := 2.0 ^ e
        eps := 1.0 / n
        A := - e * ln2()
        B := 1.0
        U := A 
        V := 1.0
        k := 1
        repeat
            B := B * n^2 / k^2
            A := (A * n^2 / k + B) / k
            if (A < eps) /\ (B < eps) then
                return U / V
            U := U + A
            V := V + B
            k := k + 1
    
    fractions:(NonNegativeInteger, Integer) -> List(Integer)
    fractions(e, n) ==
        y := gamma(e)
        l : List(Integer) := []
        for i in 0..n repeat
            f := floor(y)
            l := cons(f, l)
            y := y - f
            if y > 0 then 
                y := 1 / y
        reverse(l)
    
    )set messages prompt none
    )set messages type off
    fractions(12, 1000)
    )quit
    

    next sequence

    There doesn't seem to be a good way to read input in this system, but called like this (using the fricas fork)

    fricas -noht -eval ")read em.input )quiet" 
    

    where em.input contains the source code, will print a table of the first 1001 elements of the sequence.

    politza

    Posted 2017-07-21T15:00:01.030

    Reputation: 163

    I don't have Axiom installed on my machine, but is e=12 enough to calculate 1000 terms? Because in that case you have eps = 1 / (2 ^ 12) (I guess ^ is exponentiation?) and the terminating condition is (A < eps) /\ (B < eps) (I guess /\ is conjunction)... – user202729 – 2017-12-17T03:48:44.803

    Also, can you explain which series are you using to calculate gamma? It's not entirely obvious from the code. – user202729 – 2017-12-17T04:02:09.057

    That should be eps = 10 ^ -n. Odd that it works anyway. Series used is from Brent. There also is an axiom docker image.

    – politza – 2017-12-17T09:09:26.283

    2Welcome to PPCG! – Rɪᴋᴇʀ – 2017-12-18T01:04:41.927

    Does the next series involve group theory – Husnain Raza – 2017-12-21T18:23:49.803

    1 day left for next sequence! Is this hard enough for Java? / Anyone else working on this? – user202729 – 2017-12-23T02:34:18.973

    @HusnainRaza (Probably) yes, but this one is pretty simple. Just "have symmetry group C_{2v}". In simple terms it can be explained as "having 2 perpendicular plane of reflection". – user202729 – 2017-12-23T02:36:01.563

    I give up this time. Anyone else? Progress.

    – user202729 – 2017-12-23T15:20:59.243

    5

    297. Shakespeare Programming Language, 1460 bytes, A000161

    A000161 - Number of partitions of n into 2 squares.
    Romeo, the first square.
    Juliet, the second square.
    Othello, the input.
    Macbeth, the counter.
    Hamlet, the narrator.
    The Ghost, the temporary actor one.
    
              Act I: Main Program.
           Scene I: Retrieving Input.
    
    [Enter Hamlet and Othello]
     Hamlet:
      Listen to your heart!
    [Exeunt]
      
           Scene II: Initialization.
    
    [Enter Romeo and Juliet]
     Juliet:
      You are nothing!
    [Exit Juliet]
    [Enter Macbeth]
     Romeo:
      You are as good as me!
    [Exeunt]
    
           Scene III: Calculation.
    
    [Exeunt]
    [Enter Romeo and The Ghost]
     Romeo:
      You are as bad as the product of me and me!
    [Exit The Ghost]
    [Enter Juliet]
     Romeo:
      You are as lovely as the square root of the difference between Othello and The Ghost!
     Juliet:
      Is Othello as lovely as the sum of the product of me and me and the product of you and you?
     Romeo:
      If not, let us proceed to Scene V.
    [Exeunt]
    
           Scene IV: Add One.
    
    [Enter Romeo and Macbeth]
     Romeo:
      You are as good as the sum of yourself and a flower.
    [Exeunt]
    
           Scene V: Decision.
    
    [Exeunt]
    [Enter Romeo and Hamlet]
     Hamlet:
      You are as good as the sum of yourself and a flower.
     Romeo:
      Am I not better than the square root of Othello?
     Hamlet:
      If so, let us proceed to Scene III.
    [Exeunt]
    
           Scene VI: Ending.
    
    [Enter Hamlet and Macbeth]
     Hamlet:
      You are as good as the quotient between the sum of you and a flower and a beautiful flower. Open your heart!
    [Exeunt]
    

    Try it online!

    Next sequence: A001460 - just some trivial factorial things

    Added some padding bytes so that the next one will not be calculating on the graphs (originally 1429 bytes).

    Added more padding so that the sequence points to a 0-indexed array

    Translated code (Python):

    import math
    R, O = 0, input()              # Act I Scene I & II
    M = R                          # Act I Scene I & II
    while R <= int(math.sqrt(O)):  # Act I Scene V
     G = R * R                     # Act I Scene III
     J = int(math.sqrt(O - G))     # Act I Scene III
     if O == R * R + J * J:        # Act I Scene III
      M = M + 1                    # Act I Scene IV
     R = R + 1                     # Act I Scene V
    print (M + 1) // 2             # Act I Scene VI result = ceil(M / 2)
                                   #                because all except n=2a² are counted twice
    

    Shieru Asakoto

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 445

    5

    336. Pip, 159 bytes, A000620

    b:[1]
    c:[1]
    Fi1,a+1{
     d:0
     e:2*(i%3%2)*c@(i/3)
     Fj,i{
      Fk,i-j{
       Ij=k{ d+:b@j * b@(i-j-k-1) }
       e+:c@j * c@k * c@(i-j-k-1)
      }
     }
     bAE:d
     cAE:e//3
    }
    c@v-b@v
    

    Online demo

    Next sequence


    Basically this uses A000620 = A000625 - A000621 and the generating function relations for A000625 and A000621. I'm no chemist, but by the power of species theory I think I can reverse engineer the logic behind the g.f. relations, at least for one interpretation of the sequences. We're interested in monosubstituted alkanes, which correspond to graphs which are trees where every node has valence 4 (carbon atom) or 1 (either hydrogen atom or the substituted part, X).

    In other words, modulo the trivial cases, we have a marked carbon atom which is attached to X:

       X
       |
    a--C--b
       |
       d
    

    The 3D geometry is relevant to the symmetries. The carbon atom is at the centre of a tetrahedron, and the other four elements are at the four vertices. Rotating around the axis CX doesn't change the molecule, so we'll need to avoid double-counting.

    Note that if we consider the diagram from the perspective of e.g. a, the rest of the diagram (CXbd) can be considered as an X, and that's the heart of the recurrence logic.

    If we ignore all restrictions and symmetry then by elementary species theory we have a generating function with recurrence \$F(x) = 1 + xF(x)^3\$. The \$1\$ corresponds to the special case that there's one molecule with 0 carbon atoms (X); the \$xF(x)^3\$ says that a molecule with \$n\$ carbon items can be identified with a molecule with one (\$x^1\$) identified carbon atom and then the remaining \$n-1\$ carbons are supplied by three smaller instances of the same type of object (a, b, d).

    A000621 counts the non-stereoisomeric molecules. That means that they're symmetric: a = b, and all of a, b, d are non-stereoisomeric1. That gives generating function \$G(x) = 1 + xG(x)G(x^2)\$. The \$x\$ corresponds to the identified carbon atom C; the \$G(x)\$ corresponds to d; and the \$G(x^2)\$ corresponds to a and b being equal. (It uses \$x^2\$ to count each carbon atom in a twice).

    A000625 counts all molecules under the rotational symmetry about the axis CX. If a, b, d are all different then there are three rotational positions, so we need to divide by 3; if two of them are the same then there are still three rotational positions; if all three are the same then there is only one rotational position, so we don't want to divide by three. We have g.f. \$H(x) = 1 + \frac13 xH(x)^3 + \frac23 xH(x^3)\$ where the final term is to bring the weight of the case where a=b=d back up from \$\frac13\$ to \$1\$.


    1 Actually the choice that a = b is arbitrary, but works out nicely. We could alternatively consider the cases a = d and b = d as well, but then we have to divide by 3 to account for the symmetry.

    Peter Taylor

    Posted 2017-07-21T15:00:01.030

    Reputation: 41 901

    4

    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

    Leaky Nun

    Posted 2017-07-21T15:00:01.030

    Reputation: 45 011

    Open problem: does Lua have memoization? This should have exponential complexity... – Leaky Nun – 2017-07-21T19:10:32.150

    Hold on, you 4 people \o/ – Leaky Nun – 2017-07-21T19:14:47.077

    4

    18. APL (Dyalog), 37 bytes, A000018

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

    Try it online!

    Next sequence

    Warning: this is terribly inefficent

    user41805

    Posted 2017-07-21T15:00:01.030

    Reputation: 16 320

    @ETHproductions Yes, forgot the number – user41805 – 2017-07-21T20:03:26.667

    Note: I changed the bytecount of this solution to make it slightly easier for the next solution. cc @ETHproductions – user41805 – 2017-07-21T20:06:07.657

    2-1 for changing the next sequence for no good reason – Peter Taylor – 2017-07-21T20:09:14.317

    Oh, that'll probably be solved before I'm back at a computer then – ETHproductions – 2017-07-21T20:09:19.807

    4

    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
    ‘Ç                 !!!!!!! Called Link
    ‘                  Decrement
     Ç                 Call the Main Link
    

    HyperNeutrino

    Posted 2017-07-21T15:00:01.030

    Reputation: 26 575

    4

    23. Ruby, 23 bytes, A000982

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

    Try it online!

    Next sequence

    23rd entry uses 23 bytes!

    Justin

    Posted 2017-07-21T15:00:01.030

    Reputation: 417

    Could you format this as asked in the question please? – caird coinheringaahing – 2017-07-21T22:51:33.543

    fixed, sorry bout that – Justin – 2017-07-21T22:52:28.173

    4

    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)

    Silvio Mayolo

    Posted 2017-07-21T15:00:01.030

    Reputation: 1 817

    1Since now different compilers are considered different languages, I think you should specify which compiler you are using. – NieDzejkob – 2017-09-23T12:03:41.927

    4

    28. Positron, 9 bytes, A000584

    ->{$1**5}
    

    Try it online!

    Finally got Positron in here ^_^

    Next sequence

    HyperNeutrino

    Posted 2017-07-21T15:00:01.030

    Reputation: 26 575

    1Gosh darn it, I thought I had a chance to use Cubix, where the linear code is just I:***O@ – ETHproductions – 2017-07-22T00:51:24.110

    @ETHproductions :) Finally I managed to not get ninja'd... for once... lol – HyperNeutrino – 2017-07-22T00:52:51.777

    4

    32. C (gcc), 216 bytes, A000172

    #include <stdio.h>
    
    #define cube(x) (x)*(x)*(x)
    
    int main(int a) {
    	int n;
    	scanf("%d",&n);
    	int nCr = 1;
    	int sum = 0;
    	for(int r=0;r<=n;r++) {
    		sum += cube(nCr);
    		nCr *= n-r;
    		nCr /= r+1;
    	}
    	printf("%d",sum);
    }
    

    Try it online!

    Next sequence

    Leaky Nun

    Posted 2017-07-21T15:00:01.030

    Reputation: 45 011

    4

    33. Octave, 73 bytes, A000216

    function o=s(x)
    if x<2
    o=2;
    else
    o=sum((int2str(s(x-1))-'0').^2);
    end
    end
    

    Try it online!

    Pretty basic recursive formula.

    Next sequence

    Giuseppe

    Posted 2017-07-21T15:00:01.030

    Reputation: 21 077

    4

    45. D, 190 bytes, A000094

    int A000094(int n) {
    	if (n<4) {
    		return 0;
    	}
    	int[] gf = new int[n+1];
    	gf[0] = 1;
    	for (int i=1; i<n; i++) {
    		for (int j=i; j<=n; j++) {
    			gf[j] += gf[j-i];
    		}
    	}
    	return gf[n]-n+1;
    }
    

    Try it online!

    Next sequence

    Leaky Nun

    Posted 2017-07-21T15:00:01.030

    Reputation: 45 011

    Never thought I'd see a D answer, nice job making me use Fortress. Grr. – Zacharý – 2017-08-11T21:49:37.433

    4

    46. Jellyfish, 21 bytes, A000190

    p
    d^0
    1|&*&*r
     E    i
    

    Try it online!

    Next sequence

    caird coinheringaahing

    Posted 2017-07-21T15:00:01.030

    Reputation: 13 702

    Oh noes, it's "Number of positive integers <= 2^n of form x^2 + 12 y^2. " – Leaky Nun – 2017-07-22T13:18:38.637

    This "Jellyfish" looks like a llama – HyperNeutrino – 2017-10-31T14:04:13.750

    4

    47. awk, 194 bytes, A000021

    {
     n=0;
     for (i=1; i<=2**$1; i++) {
      stop = 0;
      for (x=0; x<=i && !stop; x++) {
       for (y=0; y<=i && !stop; y++) {
        if (x**2 + 12*y**2 == i){
         n++; stop=1;
        }
       }
      }
     }
     print n;
    }
    

    Try it online!

    Next sequence

    yoann

    Posted 2017-07-21T15:00:01.030

    Reputation: 640

    4

    alephalpha

    Posted 2017-07-21T15:00:01.030

    Reputation: 23 988

    1I swear we've already done the "partitions of N into 1,2,5,10" sequence... perhaps an answer got deleted though – ETHproductions – 2017-07-22T16:08:07.530

    I thought so too @ETHproductions but I don't see it, probably a similar sequence – Stephen – 2017-07-22T16:13:30.107

    4

    52. Ceylon, 484 bytes, A000008

    Integer f(Integer n) {
    	variable Integer coin1 = 0;
    	variable Integer coin2 = 0;
    	variable Integer coin5 = 0;
    	variable Integer coinT = 0;
    	variable Integer count = 0;
    	while (coin1 <= n) {
    		while (coin2 <= n / 2) {
    			while (coin5 <= n / 5) {
    				while (coinT <= n / 10) {
    					if (n == coin1 + 2 * coin2 + 5 * coin5 + 10 * coinT) {
    						count++;
    					}
    					coinT++;
    				}
    				coin5++;
    				coinT = 0;
    			}
    			coin2++;
    			coin5 = 0;
    		}
    		coin1++;
    		coin2 = 0;
    	}
    	return count; 
    }
    

    Try it online!

    huehue I'm a Ceylon noob

    Next Sequence (c'mon this is so easy)

    HyperNeutrino

    Posted 2017-07-21T15:00:01.030

    Reputation: 26 575

    4

    55. ><>, 41 bytes, A000196

    :1>::*$@(?vv
      ^ +1@@:$ <
              \1-n;
    

    Try it online!

    Next sequence

    fireflame241

    Posted 2017-07-21T15:00:01.030

    Reputation: 7 021

    1f=function(n,q=1){return n?n>=q?f(n-q,q)+f(n,q+1):0:1} solves A000041 in Node.JS, but it's an extremely trivial modification of another answer of mine so I don't know if I really want to post it... (also, A000054 is "Local stops on New York City A line subway", so...) – ETHproductions – 2017-07-22T16:54:35.183

    4

    57. Desmos, 119 bytes, A000138

    f\left(n\right)=n!\sum _{i=0}^{\operatorname{floor}\left(\frac{n}{4}\right)}\frac{\left(-1\right)^i}{i!\cdot 4^I}
    

    Try It Online!

    Next Sequence

    Scott Milner

    Posted 2017-07-21T15:00:01.030

    Reputation: 1 806

    \operatorname? – BlackCap – 2017-07-22T17:49:32.907

    Gosh darn it, ninja'd again... I had come up with q=n=>n?n*q(n-4)+(-n/4%2||1):1;f=n=>n?f(n-1)*(n%4?n:q(n)/q(n-4)):1 in JS which uses a similar technique – ETHproductions – 2017-07-22T17:50:08.943

    @ETHproductions That seems to be a common theme with this challenge. I've had 3 other Desmos answers that just got beat out. – Scott Milner – 2017-07-22T17:50:42.937

    @BlackCap Desmos auto-formats while you type. When you copy-paste, you get a bunch of TEX-like code, but it won't necessarily work in TEX. – Scott Milner – 2017-07-22T17:52:39.273

    Pasting the equation directly in still works with f(n)=n!\sum _{i=0}^{floor(n/4)}(-1)^i/i!/4^i. Not that you should golf it now, but... – ETHproductions – 2017-07-22T18:09:26.257

    @ETHproductions That's true. Oh well. – Scott Milner – 2017-07-22T18:17:53.323

    4

    58. 2sable, 11 bytes, A000119

    <DÅFÙïæOrQO
    

    Try it online!

    <DÅFÙïæOrQO  Program
    <            Decrement for 0-indexing
     D           Duplicate top of stack (for later use)
      ÅF         List of fibonacci numbers up to the current number
        Ù        Remove duplicates
         ï       Convert each element to an integer (they become strings for whatever reason ;_;)
          æ      Powerset
           O     Sum of each subset in the powerset
            r    Reverse stack (I don't think this is necessary, but 10 bytes isn't allowed anyway)
             Q   Equality check; vectorizes
              O  Gives number of occurrences; done
    

    Next Sequence

    HyperNeutrino

    Posted 2017-07-21T15:00:01.030

    Reputation: 26 575

    Have we not had A11 already? – BlackCap – 2017-07-22T18:24:26.763

    @BlackCap We had A46, which is similar, but is slightly different (they're very similar; you may remember me raging last night about not being able to get the definitions lol) – HyperNeutrino – 2017-07-22T18:25:04.697

    4

    62. S.I.L.O.S, 57 bytes, A000005

    readIO
    n=i
    lblb
    r=n%i
    r/r
    r=1-r
    s+r
    i-1
    if i b
    printInt s
    

    Try it online!

    Next Sequence


    *LeakyNun asked me to post this, again.

    Mr. Xcoder

    Posted 2017-07-21T15:00:01.030

    Reputation: 39 774

    4

    68. Pascal (FPC), 761 bytes, A000837

    function Mobius(n: integer): integer;
    type
    	iarray = array of integer;
    var
    	result: iarray;
    	i, j, sum: integer;
    begin
    	setlength(result,n+1);
    	result[1] := 1;
    	for i := 2 to n do
    	begin
    		sum := 0;
    		for j := 1 to i-1 do
    			if (i mod j = 0) then
    				sum := sum + result[j];
    		result[i] := -sum;
    	end;
    	Mobius := result[n];
    end;
    
    function A000837(n: integer): integer;
    type
    	iarray = array of integer;
    var
    	partitions: iarray;
    	i, j, sum: integer;
    begin
    	setlength(partitions,n+1);
    	partitions[0] := 1;
    	for i := 1 to n do
    		for j := i to n do
    			partitions[j] := partitions[j] + partitions[j-i];
    	sum := 0;
    	for i := 1 to n do
    		if (n mod i = 0) then
    			sum := sum + partitions[i] * Mobius(n div i);
    	if (n = 0) then
    		A000837 := 1
    	else
    		A000837 := sum;
    end;
    

    Try it online!

    Next sequence

    How it works

    It generates the partitions using the trivial gf:

    prod(q=[1,infty], 1/(1-x^q))
    

    and then uses the Möbius Transform.

    Leaky Nun

    Posted 2017-07-21T15:00:01.030

    Reputation: 45 011

    Anyone having the feeling that A000761(3) should be 464 instead of 468? – yoann – 2017-07-23T11:27:31.577

    4

    74. Racket, 77 bytes, A000363

    (define(a n)(/(-(expt 5 n)(*(sub1(* 2 n))(expt 3 n))(* 2 n)2(-(* 2 n n)))16))
    

    Try it online!

    Next sequence

    Business Cat

    Posted 2017-07-21T15:00:01.030

    Reputation: 8 927

    4

    75. GolfScript, 36 bytes, A000077

    ~2\?):P.*,{.P/.*\P%.*6*+}%.&{P<},0-,
    

    Online demo

    Next sequence

    Peter Taylor

    Posted 2017-07-21T15:00:01.030

    Reputation: 41 901

    This is similar to the GolfScript answer I was working on when an earlier answer was changed for no good reason. – Peter Taylor – 2017-07-24T06:19:53.917

    4

    82. Cubix, 14 bytes, A000290

    ....I:*....u@O
    

    Try it online!

    Next sequence

    Giuseppe

    Posted 2017-07-21T15:00:01.030

    Reputation: 21 077

    1Finally Cubix gets in here :-) – ETHproductions – 2017-07-24T20:54:09.650

    @ETHproductions I was in the midst of editing this one! thanks. As a note, this is actually a 6-byter but 6 was already taken. – Giuseppe – 2017-07-24T20:56:18.953

    Dang, too slow for me – Brian J – 2017-07-24T21:00:03.860

    4

    95. Taxi, 478 bytes, A000027

    Go to Post Office:w 1 l 1 r 1 l.
    Pickup a passenger going to The Babelfishery.
    Go to The Babelfishery:s 1 l 1 r.
    Pickup a passenger going to Addition Alley.
    1 is waiting at Starchild Numerology.
    Go to Starchild Numerology:n 1 l 1 l 1 l 2 l.
    Pickup a passenger going to Addition Alley.
    Go to Addition Alley:w 1 r 1 l 1 r 3 r 1 r.
    Pickup a passenger going to The Babelfishery.
    Go to The Babelfishery:n 1 r 1 r.
    Pickup a passenger going to Post Office.
    Go to Post Office:n 1 l 1 r.
    

    Adds 1 to the input, since this has to be 0-based.

    Try it online!

    Next Sequence

    Stephen

    Posted 2017-07-21T15:00:01.030

    Reputation: 12 293

    4

    102. Perl 5, 158 bytes, A000335

    @b[0]=1;
    while($n++<=$ARGV[0]){
      for($d=1;$d<=$n;$d++){
        for($k=$d;$k<=$n;$k+=$d){@b[$n]+=$d*$d*($d+1)*($d+2)/6*@b[$n-$k]}
      }
      @b[$n]/=$n
    }
    print @b[-1]
    

    Online demo. This is a full program which takes input as a command-line parameter.

    Next Sequence

    Peter Taylor

    Posted 2017-07-21T15:00:01.030

    Reputation: 41 901

    4

    104. Vala, 267 bytes, A000713

    static int main(string[] args) {
    	int n = int.parse(stdin.read_line());
    	int[] a = new int[n+1];
    	a[0] = 1;
    	for(int i=1;i<=n;i++){
    		int iter = i==1?3:2;
    		for(int j=0;j<iter;j++)
    			for(int k=i;k<=n;k++) a[k] += a[k-i];
    	}
    	stdout.printf("%d\n", a[n]);
    	return 0;
    }
    

    Try it online!

    Next sequence.

    Explanation

    Uses the g.f. 1/[(1-x)^3 (1-x^2)^2 (1-x^3)^2 (1-x^4)^2 ...].

    Leaky Nun

    Posted 2017-07-21T15:00:01.030

    Reputation: 45 011

    {a={s=[];b(it,it,s);return s.size()};b={n,m,p->if(!n){p<<0;return;};for(int i=Math.min(m,n);i>=1;i--){b(n-i, i, p);}};(0..it).sum{d->(0..d).sum{a(it)*a(d-it)}}} - so much wasted effort on my part :(. – Magic Octopus Urn – 2017-08-14T15:10:58.497

    I implemented A000041 to implement A000712 to implement A000713 xD. – Magic Octopus Urn – 2017-08-14T15:12:58.003

    4

    114. Crystal, 1560 bytes, A000228

    Dirs = [0,1,-1].permutations.to_a
    
    def addhp(a,b)
      (0..2).map{ |i| a[i]+b[i] }
    end
    
    def hexh(n,use,seen,possible)
      if n==0
        testhex(use) ? 1 : 0
      else
        if possible.empty?
          0
        else
          elem = possible[0]
          remain = possible[1..-1]
          newseen = [elem]+seen
          c = hexh(n,use,newseen,remain)
          newpossible = Dirs.map{ |d| addhp(elem,d) }
          newpossible = newpossible.select \
             { |p| ! ((seen.includes? p) || (remain.includes? p)) }
          c + hexh(n-1,use+[elem],newseen,remain+newpossible)
        end
      end
    end
    
    def hex(n)
      empty = [] of Array(Int32)
      hexh(n,empty,empty,[[0,0,0]])
    end
    
    def rot(hl)
      hl.map{ |h| h.rotate }
    end
    
    def neg(hl)
      hl.map{ |h| h.map{ |v| -v } }
    end
    
    def mirr(hl)
      hl.map{ |h| [0,2,1].map{ |i| h[i] } }
    end
    
    def normhex(hl)
      x = hl.map{ |h| h[0] }.min 
      hl = hl.map{ |h| addhp(h,[-x,0,x]) }
      x = hl.map{ |h| h[1] }.min
      hl.map{ |h| addhp(h,[0,-x,x]) }
    end
    
    def check(shl,chl)
      ( shl <=> chl.sort ) == 1
    end
    
    def testonesided(hl,ohl)
      return false if check(hl,ohl)
      nhl = normhex(rot(ohl))
      return false if check(hl,nhl)
      nhl = normhex(rot(nhl))
      return false if check(hl,nhl)
      nhl = normhex(neg(ohl))
      return false if check(hl,nhl)
      nhl = normhex(rot(nhl))
      return false if check(hl,nhl)
      nhl = normhex(rot(nhl))
      return false if check(hl,nhl)
      true
    end
    
    def testhex(hl)
      hl = normhex(hl)
      return false if hl[0] != hl.min
      hl.sort!
      mhl = normhex(mirr(hl))
      testonesided(hl,hl) && testonesided(hl,mhl)
    end
    
    n = ARGV.size==1 ? ARGV[0].to_i : 7
    puts "f(#{n}) = #{hex(n)}"
    

    Next sequence

    Try it online!

    This is a full program that takes input from the command line and computes the value for n=7 if no argument was given, because that has a nice value. I don't really know this language, it may show. And I don't know how to give command line arguments to TIO, you may just replace the assignment to n in the line before the last one instead.

    Strangely, it compiles fine (on old debian jessie using crystal's external debian repository) with crystal build hex.cr, but the optimizing call crystal build hex.cr --release fails with what seems to be an internal error.

    Christian Sievers

    Posted 2017-07-21T15:00:01.030

    Reputation: 6 366

    1partitions ಠ_ಠ – Business Cat – 2017-08-18T18:33:18.307

    2

    It seems to always output f(7) = 333 regardless of the input. (by the way, Crystal is on TIO)

    – Business Cat – 2017-08-18T18:36:05.840

    Do you run it locally? I can use command line arguments just fine. But I have no idea how to give them with TIO. And I wonder how I did not see the language there. – Christian Sievers – 2017-08-18T18:50:52.920

    @ChristianSievers I don't have it installed (and I'm on my work computer right now so I can't). I was trying to get it to work on TIO but I couldn't figure it out either, best I could tell it kept trying to open files named 6 or whatever I input. – Business Cat – 2017-08-18T18:53:33.690

    @ChristianSievers see this comment from Dennis

    – Stephen – 2017-08-18T18:59:44.003

    The compile problem is nothing special, I can't even build a hello world program with --release – Christian Sievers – 2017-08-19T10:50:08.570

    @BusinessCat TIO's handling of crystal programs has been changed. Command line arguments work as expected now. – Christian Sievers – 2017-08-20T08:23:48.407

    4

    124. ArnoldC, 796 bytes, A000278

    IT'S SHOWTIME
    
    HEY CHRISTMAS TREE input
    YOU SET US UP @I LIED
    HEY CHRISTMAS TREE result
    YOU SET US UP @I LIED
    HEY CHRISTMAS TREE x
    YOU SET US UP @I LIED
    HEY CHRISTMAS TREE y
    YOU SET US UP @NO PROBLEMO
    HEY CHRISTMAS TREE temp1
    YOU SET US UP @I LIED
    
    GET YOUR ASS TO MARS input
    DO IT NOW
    I WANT TO ASK YOU A BUNCH OF QUESTIONS AND I WANT TO HAVE THEM ANSWERED IMMEDIATELY
    
    STICK AROUND input
    
    GET TO THE CHOPPER temp1
    HERE IS MY INVITATION x
    ENOUGH TALK
    
    GET TO THE CHOPPER x
    HERE IS MY INVITATION x
    GET UP y
    ENOUGH TALK
    
    GET TO THE CHOPPER y
    HERE IS MY INVITATION temp1
    YOU'RE FIRED temp1
    ENOUGH TALK
    
    GET TO THE CHOPPER input
    HERE IS MY INVITATION input
    GET DOWN 1
    ENOUGH TALK
    
    CHILL
    
    GET TO THE CHOPPER result
    HERE IS MY INVITATION x
    ENOUGH TALK
    
    TALK TO THE HAND result
    YOU HAVE BEEN TERMINATED
    

    Try it Online!

    Next Sequence

    KSmarts

    Posted 2017-07-21T15:00:01.030

    Reputation: 1 830

    1useful for the next person, perhaps? – Giuseppe – 2017-09-01T15:16:37.507

    I WANT TO ASK YOU A BUNCH OF QUESTIONS AND I WANT TO HAVE THEM ANSWERED IMMEDIATELY: How does this work? – NieDzejkob – 2017-09-01T15:16:49.720

    @NieDzejkob GET YOUR ASS TO MARS assigns a variable from a method call, DO IT NOW calls the method, and I WANT TO ASK YOU A BUNCH OF QUESTIONS AND I WANT TO HAVE THEM ANSWERED IMMEDIATELY reads an integer input. – KSmarts – 2017-09-01T15:33:56.237

    @Giuseppe Of course, lots of math software have built-ins for arbitrary precision pi, too. – KSmarts – 2017-09-01T15:35:23.220

    @KSmarts sure, but I'm having trouble picking one that hasn't been used yet, so I provided that link as at least one example of a "roll your own" algorithm – Giuseppe – 2017-09-01T15:36:22.167

    @Giuseppe Maple is unused – NieDzejkob – 2017-09-01T15:38:52.590

    4

    168. Python 2 (PyPy), 261 bytes, A000101

    import sympy
    
    def A000101(n):
      i = 0
      p = 2
      max_difference = 0
      while i <= n:
        next_p = sympy.nextprime(p)
        if next_p-p > max_difference:
          max_difference = next_p - p
          i = i + 1
        p = next_p    
      return p
    
    print A000101(int(raw_input()))
    

    Next Sequence

    Try it online!

    Others want to starve the challenge of the use of Python, so I'll help.

    KSmarts

    Posted 2017-07-21T15:00:01.030

    Reputation: 1 830

    Might want to note that you use sympy somewhere. It's not in the standard library... – totallyhuman – 2017-09-21T16:43:24.517

    4

    174. C++ (gcc), 54 bytes, A000257

    int f(int n){return n?~-~-~-~-(n<<3)*f(~-n)/-~-~n:01;}
    
    • Try it online!
    • Next sequence: A000054 :P
    • Alternative C solution (as C (clang) and C (gcc) are not considered to be different languages, even if Python interpreters are, I switched to C++)

    Jonathan Frech

    Posted 2017-07-21T15:00:01.030

    Reputation: 6 681

    3What the hell is this next sequence... Wonder if Mathematica has a built-in – Grzegorz Puławski – 2017-09-22T12:19:50.013

    Wasn't C already used before? – NieDzejkob – 2017-09-22T12:21:24.720

    @NieDzejkob Every 150 (valid) answers, the number of times a language may be used increases. It was used once before my answer. – Jonathan Frech – 2017-09-22T12:22:29.310

    @JonathanFrech Answer 32 and 157. – NieDzejkob – 2017-09-22T12:27:04.123

    @NieDzejkob Right... I am going to use another compiler. – Jonathan Frech – 2017-09-22T12:29:18.523

    @JonathanFrech Maybe you should edit in the C++ solution so that the only interpreter stupidity is with Python? (we said python is OK because of the long chain of answers that would have to be deleted) – NieDzejkob – 2017-09-22T12:49:49.027

    1@NieDzejkob The OP said C (gcc) and C (clang) are considered to be the same language, so I switched to C++. – Jonathan Frech – 2017-09-22T14:07:15.447

    1

    Given that CPython and PyPy are considered different languages, I have reverted that decision and am going to say that clang and gcc are different languages. Please don't change this answer however, this is just for future reference.

    – caird coinheringaahing – 2017-09-22T17:43:45.787

    4

    185. Octave, 17 bytes, A000142

    @(n)factorial(n);
    

    Try it online!

    Next sequence

    Cinaski

    Posted 2017-07-21T15:00:01.030

    Reputation: 1 588

    3Next sequence just asks for some funky language. Malbolge anyone? – Grzegorz Puławski – 2017-09-26T12:12:33.553

    Next sequence is uncomputable and erroneous. I'm editing your bytecount (no code changes) to give us an actual sequence to use :) Nothing personal; we've run into this problem before edit never mind – HyperNeutrino – 2017-09-26T12:20:21.697

    If A000017 just an erroneous version of A032522 does that mean it's not really even a sequence? Would hard-coding the 19 values on OEIS count as outputting it in its entirety, then?

    – Engineer Toast – 2017-09-26T12:23:09.297

    2I believe hardcoding is permissible in this case since it's not computable / a finite sequence. – Giuseppe – 2017-09-26T13:04:16.057

    3Just hardcoding is lame. You could compute the real sequence and add a "correction" for the error. If we knew how the wrong result was obtained, we could even try to redo that... – Christian Sievers – 2017-09-26T13:57:14.300

    4

    194. ALGOL 68 (Genie), 589 bytes, A000160

    BEGIN
      LONG LONG INT n   := read int + 4;
      LONG LONG INT r   := 0;
      LONG LONG REAL ma := ( n / 4.0 ) ** 1.5;
      LONG LONG REAL mb := ( n / 3.0 ) ** 1.5;
      LONG LONG REAL mc := ( n / 2.0 ) ** 1.5;
      LONG LONG REAL x  := 2.0 / 3;
      INT a             := 1;
      WHILE a <= ma DO
        INT b := a;
        WHILE b <= mb DO
          INT c := b;
          WHILE c <= mc DO
            INT d := c;
            WHILE a ** x + b ** x + c ** x + d ** x <= n DO
              r := r + 1;
              d := d + 1
            OD;
            c := c + 1
          OD;
          b := b + 1
        OD;
        a := a + 1
      OD;
      print ( whole ( r , 0 ))
    END
    

    Try it online!

    Next Sequence.

    Based on the comments of the sequence, counts the solutions to the inequality

    a(2/3)+b(2/3)+c(2/3)+d(2/3) ≤ n

    for any four integers 1 ≤ a ≤ b ≤ c ≤ d.

    I also gave a fairly straightforward next sequence, to make up for last time.

    Edit: This was originally written for Java 8, but I missed that there were already two Java 8 answers when I wrote this. Probably because one was labeled "Java (OpenJDK 8)" and the other was just "Java 8". Whatever the reason, this answer was invalid. I re-wrote it in a different language, with the same byte count, to fix this.

    KSmarts

    Posted 2017-07-21T15:00:01.030

    Reputation: 1 830

    Note that this is valid because You can assume that neither the input nor the required output will be outside your languages numerical range – Stephen – 2017-10-02T14:07:21.607

    @Stephen You could get picky and say that it doesn't count because Java has the "long" type, but that's an easy fix. All of the test cases on the OEIS page fit in 32-bit integers anyway. – KSmarts – 2017-10-02T14:20:08.327

    Oh, right, I forgot about that. It needs to work for n=0 to 1000 then or it is invalid (since you also have BigInteger) – Stephen – 2017-10-02T14:22:41.283

    1@Stephen Fixed (Byte count unchanged). – KSmarts – 2017-10-02T14:47:42.457

    4

    199. Kotlin, 92 bytes, A000466

    fun main(args: Array<String>){
        val n = Integer.valueOf(args[0]);
        println(4*n*n-1);
    }
    

    Try it online!

    Next Sequence

    Stephen

    Posted 2017-07-21T15:00:01.030

    Reputation: 12 293

    4

    207. ARBLE, 389 bytes, A003275

    coprime = eq(max((#table.unpack)(where(range(1,max(a,b)),eq(d%first(a,b,c,d,e),0)*eq(e%a,0),a,b))),1)
    phi = len(where(range(1,n),coprime(a,first(n,b,c)),n))
    A003275 = list()
    local A003275_n = 0
    return function(n)
    	while(#A003275 < n)do
    		A003275_n = A003275_n + 1
    		if(phi(A003275_n) == phi(A003275_n+1))then
    			A003275[#A003275+1] = phi(A003275_n)
    		end
    	end
    	return A003275[#A003275]
    end
    

    Try it online!

    Next Sequence

    ATaco

    Posted 2017-07-21T15:00:01.030

    Reputation: 7 898

    4

    225. VBA, 80 bytes, A001232

    Sub s(n)
    While k<n+1
    i=i+1
    If i*9=StrReverse(i) Then k=k+1
    Wend
    MsgBox i
    End Sub
    

    Next sequence

    Output is a popup message. A not-very-exciting sequence deserves a not-very-exciting solution, I think.

    Engineer Toast

    Posted 2017-07-21T15:00:01.030

    Reputation: 5 769

    I hate the fact that can't see that a new answer showed up without scrolling to the top or reloading the page... At least I learned the basics of a new language. – NieDzejkob – 2017-10-12T13:59:19.367

    1C for next seq – NieDzejkob – 2017-10-12T14:03:03.983

    @NieDzejkob Same here. I (sort of) know Perl now. – KSmarts – 2017-10-12T14:54:27.123

    4

    235. Pascal (FPC), 3295 bytes, A000512

    4 days passed without anyone answered.

    Type
    	int = LongInt; // Can be changed to Integer
    
    Var
    	n, n_column, matrices_len, i, j, k: int;
    	row_values, matrices: Array of array of int;
    	row_id, column_sum: Array of int;
    	valid: Boolean;
    
    Function next_permutation (var A : Array of int): Boolean;
    var x, y, z, temp: int;
    begin
    	if Length(A) <> n then writeln('Error!!');
    	x := Length(A) - 1; // or High(A)
    	z := x;
    	while (x > 0) and (A[x-1] > A[x]) do Dec(x);
    	y := x;
    	while y < z do
    	begin
    		temp := A[z]; A[z] := A[y]; A[y] := temp;
    		Inc(y); Dec(z);
    	end;
    	if (x = 0) then
    		Exit(false);
    	y := x; temp := A[x-1];
    	while A[y] < temp do Inc(y);
    	A[x-1] := A[y]; A[y] := temp;
    	Exit(true);
    end;
    
    Function equivalent (mat1, mat2: int): Boolean;
    { Use highly sub-optimal solution, O(n!^2 x n^2).
      O( n! x n^2 x log(n) ) solution is possible by trying all row permutation
      and sort the columns, and check if the matrices are equal.
      Sort the rows and the columns alternatively does not work, though.
    }
    var
    	xP, yP: Array of int;
    	x, y: int;
    	different: Boolean;
    begin
    	SetLength(xP, n);
    	SetLength(yP, n);
    	for x := 0 to n-1 do
    	begin
    		xP[x] := x;
    		yP[x] := x;
    	end;
    	repeat
    		repeat
    			different := false;
    			for x := 0 to n-1 do
    			begin
    				for y := 0 to n-1 do
    				begin
    					if row_values[matrices[mat1, x], y] <>
    					row_values[matrices[mat2, xP[x]], yP[y]] then
    					begin
    						different := true;
    						break;
    					end;
    				end;
    				if different then break;
    			end;
    			if not different then Exit(true);
    		until not next_permutation(xP);
    	until not next_permutation(yP);
    	Exit(false);
    end;
    
    Begin
    	Read(n); Inc(n);
    	If n < 3 then
    	begin
    		Writeln(0);
    		Halt;
    	end;
    	SetLength(row_values, (n * (n - 1) * (n - 2)) div 6);
    	n_column := 0;
    	for i := 0 to n-1 do
    		for j := i+1 to n-1 do
    			for k := j+1 to n-1 do
    			begin
    				SetLength(row_values[n_column], n);
    				row_values[n_column, i] := 1;
    				row_values[n_column, j] := 1;
    				row_values[n_column, k] := 1;
    				Inc(n_column);
    			end;
    	// Dynamic array in FP is 0-based
    	if n * (n - 1) * (n - 2) <> 6 * n_column then
    	begin
    		WriteLn('Error!');
    		exit();
    	end;
    
    	matrices_len := 0;
    	SetLength(matrices, 4);
    
    	SetLength(row_id, n);
    	SetLength(column_sum, n);
    	while true do
    	begin
    		for i := 0 to n-1 do column_sum[i] := 0;
    
    		for i := 0 to n-1 do
    		begin
    			for j := 0 to n-1 do
    				Inc(column_sum[j], row_values[row_id[i], j]);
    		end;
    
    		valid := true;
    		for i := 0 to n-1 do
    		begin
    			if column_sum[i] <> 3 then // column_sum[i] = sum of all values on column i
    			begin
    				valid := false;
    				break;
    			end;
    		end;
    		if valid then
    		begin
    			if matrices_len = length(matrices) then
    				SetLength(matrices, 2 * length(matrices));
    			matrices[matrices_len] := copy(row_id, 0, n);
    			Inc(matrices_len);
    		end;
    
    		i := n - 1;
    		while (i <> -1) and (row_id[i] = n_column - 1) do
    			Dec(i);
    		if i = -1 then
    			Break;
    		Inc(row_id[i]); Inc(i);
    		while i < n do
    		begin
    			row_id[i] := row_id[i-1];
    			Inc(i);
    		end;
    	end;
    
    	row_id := nil; column_sum := nil;
    
    	k := 0;
    	for i := 0 to matrices_len-1 do
    	begin
    		valid := true;
    		for j := 0 to i-1 do
    		begin
    			if matrices[j, 0] <> -1 then
    			begin
    				if equivalent(i, j) then
    				begin
    					valid := false;
    					break;
    				end;
    			end;
    		end;
    		if valid then
    			inc(k)
    		else
    			matrices[i, 0] := -1;
    	end;
    	Writeln(k);
    End.
    
    

    Try it online!

    Next sequence.

    I can easily delete a byte to get this sequence instead (which seems to be much easier to understand), but I didn't do that.

    user202729

    Posted 2017-07-21T15:00:01.030

    Reputation: 14 620

    2@HusnainRaza Comment downvote. (Don't hardcode the sequence!) – user202729 – 2017-10-26T04:46:28.890

    4

    236. Axiom, 341 bytes, A003295

    qpc(n,k) ==  -- inspired by 3rd PARI code for A010815
      qr := divide(n,k)
      if qr.remainder>0 then return 0
      sq := perfectSqrt(24*qr.quotient+1)
      sq case "failed" => 0
      jacobi(12,sq)
    
    qp(k) == series(n+->qpc(n,k),'q=0)
    
    q := series q
    
    F := q*qp(3)*(qp(33)/(qp(1)*qp(11)))
    
    s := q*(-11+(1+3*F)^2*(1/F+1+3*F))
    
    f(n) == coefficients(s).(n+1)
    

    Next sequence.

    Put it in a file called a003295.input and, at the axiom prompt, type )read a003295. Now you can for example call f 25. The first time it will give a warning before still giving the correct result. Here it is computing the first values:

    (9) -> [f n for n in 0..20]
       Cannot compile map: f 
       We will attempt to interpret the code.
    
       (9)
       [1, - 5, 17, 46, 116, 252, 533, 1034, 1961, 3540, 6253, 10654, 17897, 29284,
        47265, 74868, 117158, 180608, 275562, 415300, 620210]
                                                  Type: List(Expression(Integer))
    

    qp(k) computes the series of the q-Pochhammer symbol for q^k. The definition of F and s follows the Mathematica code.

    Christian Sievers

    Posted 2017-07-21T15:00:01.030

    Reputation: 6 366

    could have used coefficient(s,n) – Christian Sievers – 2017-10-27T13:59:28.723

    I wonder if I should upvote or downvote this answer. – user202729 – 2017-10-27T14:00:34.343

    1@user202729 why would you downvote? – Christian Sievers – 2017-10-27T14:01:45.723

    Can you add an explanation what is the sequence? – user202729 – 2017-10-29T14:03:06.997

    @user202729 I hardly understand the basics of what is said in the OEIS entry, so I'm not sure what I can explain. But I like that it is related to the fascinating phenomenon of monstrous moonshine. – Christian Sievers – 2017-10-29T18:31:33.760

    4

    256. Pygmy Forth, 562 bytes, A000454

    CODE PICK  dpush(_stack[~dpop()]) END-CODE
    : COEFFICIENT-A(N-1) 2 * 5 - 2 * ;
    : COEFFICIENT-A(N-2) DUP 6 - * 6 * 55 + ;
    : COEFFICIENT-A(N-3) DUP DUP 7 - * 2 * 25 + SWAP 2 * 7 - * ;
    : COEFFICIENT-A(N-4) 4 - DUP * DUP * ;
    : ADVANCE DUP COEFFICIENT-A(N-1) 2 PICK * OVER COEFFICIENT-A(N-2) 4 PICK * - OVER COEFFICIENT-A(N-3) 5 PICK * + OVER COEFFICIENT-A(N-4) 6 PICK * - SWAP 1 + ;
    CODE ADVANCE-LOOP  for i in range(dpop()): ADVANCE() END-CODE
    CODE CLEAN-STACK  global _stack; _stack = [_stack[-1]] END-CODE
    : A000454 0 0 0 1 5 5 PICK ADVANCE-LOOP DROP CLEAN-STACK ;
    

    Next sequence!

    Nice, round number of answers! Computes up to 16 A454 on 64-bit Forths, and you can Try It Online! on gforth with some modifications. However, Pygmy Forth is arbitrary precision and it can compute n=1000 in a blink of an eye.

    Explanation

    Forth is a stack-based language, like 05AB1E or Actually, but it was not designed that way to be esoteric. Forth was designed in 1970, and being stack based allowed the interpreter to fit in extremely small space - even now, an x86 interpreter could fit in the MBR and VBR (two 512 byte sectors) of a hard disk, with the code loaded from a FAT32 filesystem (first-hand experience). The most important consequences of the stack-oriented design are the postfix notation in which all calculations are described, and having to keep the words ("functions") small so you don't get lost. Breaking up a word into smaller chunks is called factoring.

    ADVANCE expects the last 4 numbers of the sequence on the stack, with a cherry the sequence index n on top, and calculates the next number in the sequence as well as increments n. The sequence can start as 0, 0, 0, 1, and the next number will be assigned the index of 5, so you can calculate a specific element of the sequence like this:

    0 0 0 1 5 ADVANCE ADVANCE ADVANCE ADVANCE ADVANCE
    DROP ( the index )
    . ( print )
    

    Now we only need to loop ADVANCE a given number of times, and this is exactly what A454 does. The 0 0 0 1 5 at the beginning initializes the stack, then 5 PICK brings the argument this word was given to the top. Normally in Forth, one would do limit start ?DO stuff LOOP, which is a construct equivalent to Python's for i in range(start, limit): stuff. However, Pygmy Forth is missing a lot of words, so I have to make up for it with CODE, which is used to define words in Python. At the end of A454, DROP is used to remove the sequence index, leaving the result at the top of the stack.

    NieDzejkob

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 630

    4

    260. Brain-Flak, 504 bytes, A001333

    <>       # switch to another stack
    (())(()) # push two 1s. Assuming top = a n-1, second top = a n-2 apart from the input
    <>({}<>) # transfer the input to this stack
    {        # repeat input times
        ({}[()]<     # subtract 1, ignore 
          (
            ({}<>)   # move top a n-1 to another stack
            ({})     # + top a n-1
            <>{}<>   # add to a n-2 on the other stack
          )          # and push 2 * a n-1 + a n-2
        >)           # and push back again
    }
    {}{}     # remove redundant values on top 
    

    Try it online!

    Next sequence.

    The actual code is only 52 bytes: Try it online!

    Use the recurrence relation

    a(n) = 2a(n-1) + a(n-2)

    described on the OEIS page.


    The mathematical information about that sequence is pretty simple and elementary, and not worth the effort I write the explanation, so I decide to not write explanation for this sequence.

    user202729

    Posted 2017-07-21T15:00:01.030

    Reputation: 14 620

    1Huh, using the explanation as the actual program. Original, +1 – caird coinheringaahing – 2017-11-24T08:00:09.820

    Note that 503 is already used. I switch to 504. – user202729 – 2017-11-24T08:01:01.060

    4

    261. Alice, 115 bytes, A000504

    /
     i                            >'Qa*:\ o
      /.!.h*?2Ea*?a5+*+2+*?2*3+.!w=
                                  >?*?2-.!K @
    

    Try it online!

    Next sequence.

    Uses the formula used by the Mathematica snippet on OEIS:

    a[n_] := n (n+1) (10n^2+15n+2) (2n+3)!! / 810
    

    In detail:

    /      Switch to Ordinal mode.
    i      Read all input as a string.
    /      Switch back to Cardinal mode.
    .!     Implicitly convert the input to an integer N and store a copy on the tape.
    .h*    Multiply N by (N+1).
    ?2E    Retrieve a copy of N and square it.
    a*     Multiply by 10.
    ?a5+*  Retrieve another copy of multiply it by 15.
    +      Add the last two results.
    2+     Add 2.
    *      Multiply the initial value by this, giving N*(N+1)*(10N^2+15N+2)
    ?2*3+  Retrieve another copy of N and compute 2N+3, which will be our
           iterator for the double factorial.
    .!     Store a copy of this on the tape.
    w      Push the current IP address to the return address stack. This starts
           a loop.
      =      Sign junction. Pops the current value of the double factorial iterator.
             If it's positive, turn right (continuing the loop). If it's negative,
             turn left (exiting the loop).
      >      Redirect the IP eastward again.
      ?*     Multiply our result by the current value of the iterator.
      ?2-    Retrieve another copy of the iterator and subtract 2.
      .!     Store a copy on the tape to update the iterator.
    K      Jump back to the w to get to the next iteration.
    
           Once we exit the loop, we continue here:
    >      Redirect the IP eastward again.
    'Qa*:  Divide the result by 810 (computed as 81*10).
    \      Switch to Ordinal mode.
    o      Implicitly convert the result to a string and print it.
    @      Terminate the program.
    

    Martin Ender

    Posted 2017-07-21T15:00:01.030

    Reputation: 184 808

    4

    262. Cubically, 91 bytes, A000115

    $:7*1+4/1**1+55/1RFD'/2%:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    

    Try it online!

    Next sequence.

    Use the formula

    a(n) = round((n+4)^2/20).

    listed on the OEIS page.

    Originally I intended to format the code as a cube, something like

      $:7*1
     +    4
    /1**1 +
    5   5 /
    1   RF
    D'/2%
    

    but it does not work out too well, because Cubically does not have comments and it is not allowed to put spaces between command and parameters, unfortunately.

    More explanation later.

    user202729

    Posted 2017-07-21T15:00:01.030

    Reputation: 14 620

    The Cubically interpreter now allows arbitrary whitespace in source code. Thanks for prompting me to redo the interpreter, I've been trying to get around to that for months :) – MD XF – 2017-11-25T23:52:23.307

    4

    309. Haskell, 699 bytes, A003025

    import Control.Monad
    import Data.List
    
    -- (n, es) has n nodes; es is a list of (i,j) where 1 <= i < j <= n.
    type Dag = (Int, [(Int, Int)])
    
    both f (a,b) = (f a, f b)
    powerset = filterM (const [True, False])
    
    -- All dags with n nodes.
    dags :: Int -> [Dag]
    dags n = map ((,) n) $ powerset [(i,j) | i <- [1..n], j <- [i+1..n]]
    
    -- Is there only one node with no exits?
    ok :: Dag -> Bool
    ok (n, es) = not $ any (\i -> not $ any ((==i) . fst) es) [1..n-1]
    
    -- All ways to relabel the given dag.
    rewrites :: Dag -> [Dag]
    rewrites (n, es) = [(n, sort $ map (both ((p!!) . pred)) es) | p <- permutations [1..n]]
    
    -- A003025
    f :: Int -> Integer
    f = genericLength . nub . concatMap rewrites . filter ok . dags
    

    Try it online!

    Enumerates the n-node labeled acyclic digraphs with 1 out-point.

    print (f 5) produces the correct output (16885) after 20 seconds when compiled with -O3.

    Next sequence

    Lynn

    Posted 2017-07-21T15:00:01.030

    Reputation: 55 648

    4

    314. M, 4166 bytes, A000146

    I hope I didn’t accidentally add any bytes outside of the M code page in the code.

    The actual source code is the markdown source of this post. To prevent infinite recursion, the source can be found here.

    Try it online! (with anti-infinite-recursion)

    Next sequence!

    Explanation

    ® ÆD ‘ ÆPÐf İ           ḷ“   First link. Calculate Sum_{(p-1)|2n} 1/p, with
                                 the value of 2n stored in the register.
    ® ÆD                         All divisors of 2n (possible values of (p-1).
         ‘                  ḷ“   Increment. Get all possible values of (p).
           ÆPÐf                  Filter, keep only prime values.
                İ                Inverse.       ”
    -* ×c@ × *®¥            ḷ“   Second (dyadic) link. Given v and k, calculate
                                 (-1)^v * (k choose v) * v^m / (k+1). (m = 2*n),
                                 a term from the closed-form formula.
    -                            Literal -1.
     *                           Power. Current value = (-1)^v.
       ×c@                       Multiply (×) by the combination (c) with swapped (@)
                                 arguments applied on k and v.
           × *®¥                 Multiply by the value of dyad applied on v...
             *                     Raise to power...
              ®                    register value (currently have value m = 2n)   ”
    ‘ Ḥ© 0r µ0r ç€ ÷‘µ€ ;-£ FS ḷ“ Main link.
    ‘                          ḷ“ Increment.
      Ḥ©                          Unhalve (double) the value, and store to register.
         0r                       Generate range from 0.
            µ........µ€           For each value (k),
             0r                     generate range from 0 (values (v)),
                ç€                  apply previous range for each element,
                   ÷‘          ḷ“   and divide by (k+1).
                        ;-£       Concatenate the resulting list with the value of
                                    the first link. x£ is "call link index x as a
                                    nilad, excluding the main link, and wrap around".
                           FS     Flatten, and sum.         ”
    

    user202729

    Posted 2017-07-21T15:00:01.030

    Reputation: 14 620

    Another bignum sequence... this one is easy enough, please don't use Hy. (or another-Python-variant) – user202729 – 2018-01-17T08:13:10.137

    1I think you should edit in an explanation of how the polyglot works ;) – NieDzejkob – 2018-01-17T14:06:22.597

    This answer broke the snippet, but I will nudge the regex used to make it work. – NieDzejkob – 2018-01-17T14:30:20.907

    Is M just an early version/precursor of Jelly? – dylnan – 2018-01-17T21:34:36.250

    @dylnan Infinite precision version. – user202729 – 2018-01-18T04:06:57.230

    @user202729 Interesting. Could you demonstrate how they're different? What would be a program that differs between the two? – dylnan – 2018-01-18T04:10:24.957

    1

    @dylnan Numerical inaccuracy. This also works (adding ceiling will make the difference more explicit).

    – user202729 – 2018-01-18T04:13:58.807

    @user202729 Thanks. Apparently zoo means infinity in M

    – dylnan – 2018-01-18T04:23:54.690

    4

    315. Befunge-98 (PyFunge), 147 bytes, A004166

    very simple :)
    >"HTRF"4(1&>:!#v_1v <-- this loop here
      @.$<--out^\*3 \-< <-- calculates 3^n
     >;#_^#:/a\+%aO<\;#z<-- and here the digits are summed
    

    Try it online!

    Next sequence!

    NieDzejkob

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 630

    dagnabbit, I had a snobol solution all ready, I was just testing it :( here it is, looks like it's correct.

    – Giuseppe – 2018-01-17T15:45:36.533

    @Giuseppe well, I got ninjad on the previous sequence - I was working on a Trefunge solution and I had the Bernoulli numbers working, I just had to add the reciprocals of prime divisors. – NieDzejkob – 2018-01-17T16:13:29.093

    Again, a trailing newline is necessary. So v = ... – user202729 – 2018-01-18T04:17:12.513

    Looks like I have to post the next answer. 38 hours left. – user202729 – 2018-01-23T01:38:02.097

    4

    332. tinylisp, 852 bytes, A000766

    (d in (q ((x xs) (i (e x (h xs)) 1 (i xs (in x (t xs)) 0
    
    (d vec (q ((x y z) (c x (c y (c z (
    (d + (q ((x y) (i x (c (a (h x) (h y)) (+ (t x) (t y))) (
    
    (d map (q ((f xs) (i xs (c (f (h xs)) (map f (t xs))) (
    
    (d sub (q ((exp pat rep) (i (e exp pat) rep (i (e (type exp) (q List)) (i exp (c (sub (h exp) pat rep) (sub (t exp) pat rep)) ()) exp
    (d qt (q ((x) (c (q q) (c x (
    
    (d - (s 0 1
    (d adj (c (vec 1 1 0) (c (vec - 1 0) (c (vec 1 - 0) (c (vec - - 0) (c (vec 1 0 1) (c (vec - 0 1) (c (vec 1 0 -) (c (vec - 0 -) (c (vec 0 1 1) (c (vec 0 - 1) (c (vec 0 1 -) (c (vec 0 - -) (
    
    (d sum (q ((ls) (i ls (a (h ls) (sum (t ls))) 0
    
    (d sol (q ((ve pre n) (i (in ve pre) 0 (i n (sum (map (sub (sub (sub (q ((aj) (sol (+ VEC aj) PRE N))) (q VEC) (qt ve)) (q PRE) (qt (c ve pre))) (q N) (qt (s n 1))) adj)) (e (h ve) 1
    
    (d main (q ((x) (sol (vec 0 0 0) () (a 1 x
    

    Try it online!

    Next sequence! Intentionally chosen to be easy. (somewhat weird, too)

    ... It was (not) fun learning this language.

    Defines a function main which calculates the required function. tinylisp doesn't support reading from standard input.

    Brute force approach. That's why it's terribly slow.


    ... There is library to load? In an esoteric language? Surprise!

    user202729

    Posted 2017-07-21T15:00:01.030

    Reputation: 14 620

    No line has a trailing ). – user202729 – 2018-02-10T15:25:02.897

    Hey, thanks for using my language. :) Sorry your learning experience was painful... If you have suggestions on how I can make tinylisp more approachable, I'd love to hear them! (Chat room here)

    – DLosc – 2018-02-10T19:03:01.007

    4

    344. Proton, 301 bytes, A000382

    p = a => {
    	if len(a) == 1 return [a]
    	values = []
    	for i : 0 .. len(a)
    		for j : p(a[to i] + a[i + 1 to])
    			values.append([a[i]] + j)
    	return values
    }
    
    a = n => {
    	total = 0
    	n += 4
    	for j : p(0 .. n)
    		if all((j[i] - i) % n < 4 for i : 0 .. n)
    			total++
    	return total
    }
    
    print(a(int(input())) / 4)
    

    Try it online!

    Next sequence.

    This code takes a long time on n = 2 and I don't want to try testing it on larger cases :P In theory, it works for all cases; the code is an exact implementation of the sequence description, so no fancy math stuff that could break.

    Inefficient Coding 101 with Hyper Neutrino \o/

    (this is intentionally posted from my bot account. someone downvoted one of my posts and now I only have 19 reputation, which isn't enough to chat. and also I'm not going to go upvote it with my main account because that's evil, so I'm making a new post to earn some reputation, hopefully)

    NeutrinoBot

    Posted 2017-07-21T15:00:01.030

    Reputation: 59

    does it count as chaining myself if I use a different account LOL (obviously yes) – HyperNeutrino – 2018-02-28T02:10:22.823

    The next sequence should be rather easy; ÆḞ2* should work in Jelly. – HyperNeutrino – 2018-02-28T02:13:48.077

    3

    48. SOGL, 3 bytes, A000194

    .√Ρ
    

    Next sequence

    dzaima

    Posted 2017-07-21T15:00:01.030

    Reputation: 19 048

    @cairdcoinheringaahing There's no way I can't solve it in 2 days – Leaky Nun – 2017-07-22T14:20:06.507

    @cairdcoinheringaahing you don't need to worry about not solving it until a couple days have passed :P – Stephen – 2017-07-22T14:37:00.243

    3

    53. Coffeescript, 34 bytes, A000484

    alert Math.round Math.cos prompt()
    

    Try it online!

    Next sequence

    BlackCap

    Posted 2017-07-21T15:00:01.030

    Reputation: 3 576

    @StepHen The next one is super easy too – BlackCap – 2017-07-22T16:26:02.810

    Man, the next one is so easy, too bad I can't post yet... This would be ....I2%:)O@ in Cubix (could be shorter but 9 and 10 are already taken) – ETHproductions – 2017-07-22T16:26:08.317

    @BlackCap yup I got it in :P – Stephen – 2017-07-22T16:28:23.953

    3

    54. C# (.NET Core), 196 bytes, A000034

    using System;
    namespace A000008
    {
        class Program
        {
            static void Main(string[] args)
            {
               Console.WriteLine(1 + Int32.Parse(Console.ReadLine()) % 2);
            }
        }
    }
    

    Try it online!

    Next Sequence

    Stephen

    Posted 2017-07-21T15:00:01.030

    Reputation: 12 293

    lol the next one literally has a builtin in Jelly xD – HyperNeutrino – 2017-07-22T16:32:22.767

    3

    56. Pony, 138 bytes, A000041

    fun f(n: U64, q: U64 = 1): U64 =>
      if n>0 then
        if n>=q then
          f(n-q, q)+f(n,q+1)
        else
          0
        end
      else
        1
      end //a
    

    Try it online! (Thank you for adding Pony Dennis!)

    Next sequence

    BlackCap

    Posted 2017-07-21T15:00:01.030

    Reputation: 3 576

    1

    Try this: http://playground.ponylang.org/

    – Stephen – 2017-07-22T17:58:41.017

    1I add most languages by request. Assuming this is one, I'll look into Pony. – Dennis – 2017-07-22T18:05:18.280

    @StepHen Thanks, that worked. – BlackCap – 2017-07-22T18:11:07.880

    @Dennis Thank you, I appreciate that – BlackCap – 2017-07-22T18:59:07.350

    3One Pony, as requested. In the future, if you find a language you'd like to see added to TIO, please don't hesitate to leave me a message in http://talk.tryitonline.net. – Dennis – 2017-07-23T05:44:25.227

    3

    60. Oasis, 5 + 2 = 7 bytes, A000059

    +2 bytes for the N and o flags.

    Code:

    x4m>p
    

    Try it online!

    Explanation:

    x      # Double the number
     4m    # Raise to the power of 4
       >   # Add one
        p  # Check for primality
    

    Used with the following flags:

    • N: Find the Nth number that satisfies each line of code
    • o: Shift the sequence by 1 (N = N + 1).

    Next sequence

    Adnan

    Posted 2017-07-21T15:00:01.030

    Reputation: 41 965

    Can't believe that we haven't had A7 – Leaky Nun – 2017-07-22T20:00:08.030

    3

    caird coinheringaahing

    Posted 2017-07-21T15:00:01.030

    Reputation: 13 702

    3

    64. LiveScript, 152 bytes, A000108

    f = (n) ->
      ns = [1]
      for i from 0 to n-1
        ns.push 0
        s = 0
        for k from 0 to ns.length-1
          s += ns[k]
          ns[k] =  s
      ns[ns.length-1]
    

    Try it online!

    Next sequence

    BlackCap

    Posted 2017-07-21T15:00:01.030

    Reputation: 3 576

    Great, I don't even understand how 2 becomes 32 in this one – ETHproductions – 2017-07-22T23:21:01.340

    @ETHproductions Would you rather have had A151? – BlackCap – 2017-07-22T23:22:25.473

    ...no, sorry to complain :P You could have golfed it though – ETHproductions – 2017-07-22T23:29:57.033

    Oh, it's 0-indexed. That makes more sense I suppose – ETHproductions – 2017-07-22T23:33:15.770

    @ETHproductions They are considering 0 to be a square and they care about order, for small n this is just how many binary strings of length 16 are there containing n ones. – Post Rock Garf Hunter – 2017-07-22T23:47:17.893

    1@WheatWizard You have to account for -1s as well though, hence why 1 is 32 as opposed to 16. – ETHproductions – 2017-07-22T23:57:21.747

    This is quite apparent from the g.f. presented in the maple code: (sum(x^(m^2), m=-10..10))^16 – Leaky Nun – 2017-07-23T04:22:51.743

    3

    65. Fortran (GFortran), 371 bytes, A000152

    function A000152(n)
    	integer :: n, i, a, sum, index, A000152
    	integer, dimension(n+1) :: gf
    	gf(1) = 1
    	do i=2,n+1
    		gf(i) = 0
    	end do
    	do a=1,16
    		do i=n+1,2,-1
    			sum = 0
    			index = 1
    			do while (index * index < i)
    				sum = sum + 2 * gf(i - index * index)
    				index = index + 1
    			end do
    			gf(i) = gf(i) + sum
    		end do
    	end do
    	A000152 = gf(n+1)
    end function A000152
    

    Try it online!

    Next sequence

    How it works

    It uses the following gf:

    (sum(m=[-infty,infty], x^(m^2)))^16
    

    Leaky Nun

    Posted 2017-07-21T15:00:01.030

    Reputation: 45 011

    3

    66. Yacas, 43 bytes, A000371

    f(n):=Sum(k,0,n,(-1)^(n-k)*Bin(n,k)*2^2^k);
    

    Try it online!

    Next sequence

    alephalpha

    Posted 2017-07-21T15:00:01.030

    Reputation: 23 988

    3

    70. Elm, 1134 bytes, A000333

    import Html exposing (text)
    
    f n s = let l = takeWhile (\x -> (s + sqrt (toFloat x)) <= n) (List.range 1 (floor (n*n)))
            in List.map (\x -> [x]) l 
            ++ (List.concatMap (\x -> List.map (\y -> x::y) ( f n (s+sqrt (toFloat x)) )) l)
    
    t n = List.length(List.map List.head(group(List.sort(List.map List.sort(f(n+1)0)))))
    
    main = text (toString (List.length (t 5)))
    
    
    takeWhile : (a -> Bool) -> List a -> List a
    takeWhile predicate list =
      case list of
        []      -> []
        x::xs   -> if (predicate x) then x :: takeWhile predicate xs
                  else []
    
    dropWhile : (a -> Bool) -> List a -> List a
    dropWhile predicate list =
      case list of
        []      -> []
        x::xs   -> if (predicate x) then dropWhile predicate xs
                  else list
    
    span : (a -> Bool) -> List a -> (List a, List a)
    span p xs = (takeWhile p xs, dropWhile p xs)
    
    groupBy : (a -> a -> Bool) -> List a -> List (List a)
    groupBy eq zs =
      case zs of
        [] -> []
        (x::xs) -> let (ys,zs) = span (eq x) xs
                  in (x::ys)::groupBy eq zs
    
    group : List a -> List (List a)
    group = groupBy (==)
    

    This is much prettier in Haskell, but it has been used.


    Try it online!

    Next sequence

    BlackCap

    Posted 2017-07-21T15:00:01.030

    Reputation: 3 576

    but it has been used. by you :P – Stephen – 2017-07-23T20:35:46.250

    3

    71. F# (Mono), 401 bytes, A001134

    That was quite an experience, using a language I've never tried before which is based on a bunch of programming paradigms I've never experienced before...

    let isprime p =
      let mutable q = 2
      while q * q < p && p % q > 0 do
        q <- q + 1
      p >= 2 && q * q > p
    
    let isA001134 p =
      let mutable i = 1
      let mutable g = 2
      while g <> 1 do
        g <- g * 2 % p
        i <- i + 1
      i * 4 = p - 1 && isprime p
    
    let A001134 n =
      let mutable q = n
      let mutable result = 113
      while q > 0 do
        result <- result + 4
        if isA001134 result then q <- q - 1
      result
    

    Try it online!

    Next sequence

    ETHproductions

    Posted 2017-07-21T15:00:01.030

    Reputation: 47 880

    3

    77. Braingolf, 51 bytes, A004147

    m32&gM9784&gM7571840&gM11140566368&gMvvcv1+[R<v]v_;
    

    Try it online!

    Next sequence

    Skidsdev

    Posted 2017-07-21T15:00:01.030

    Reputation: 9 656

    According to this answer, the number of 5-state Turing machines which halt is 32. :p And then it just keeps cycling through the same four numbers – Peter Olson – 2017-07-24T16:49:19.280

    @PeterOlson actually according to this answer the number of 4-state halting machines is 32, but it's irrelevant because the numbers are incomputable, and unknown beyond n=3 – Skidsdev – 2017-07-24T18:11:21.653

    3

    78. anyfix, 12 bytes, A000051

            2«*‘
    

    Try it online!

    Next Sequence

    Note: TIO says 15 bytes but that's because I haven't asked Dennis to configure Anyfix to use the Jelly codepage yet.

    HyperNeutrino

    Posted 2017-07-21T15:00:01.030

    Reputation: 26 575

    3

    79. Commentator, 13 bytes, A000012

     */          
    

    Try it online!

    Next Sequence

    A space increments the accumulator and */ outputs it as a number. As the program has outputted, the spaces at the end are essentially no-ops.

    caird coinheringaahing

    Posted 2017-07-21T15:00:01.030

    Reputation: 13 702

    3

    86. Gaia, 40 bytes, A00097

    1w×ḍΣ¦¦ȯ¦u⟨:l0₁,*¤⟪¤;3<×\?⟫†¦ȯ¦u⟩¦e¦l:!+
    

    Next sequence

    Business Cat

    Posted 2017-07-21T15:00:01.030

    Reputation: 8 927

    3

    87. Neim, 16 bytes, A000040

    >1><><><><><><
    

    Output is wrapped in braces []. Yes, those are random filler bytes (that increment and decrement continuously), but I like to think of them as fish having fun with code.

    Try it online!

    Next sequence.

    totallyhuman

    Posted 2017-07-21T15:00:01.030

    Reputation: 15 378

    2i don't know, I think it looks like a fish double date ><><>< ><><>< – BlackCap – 2017-07-25T14:49:37.407

    You can replace 1 (get last 1 elements) with `` (get greatest element) if you want output without braces. Also, you can use Q as a filler (terminate program) or a space character. – Okx – 2017-07-26T11:41:38.570

    @Okx Why do you want no fish dates? – NieDzejkob – 2017-09-05T05:24:30.410

    3

    90. Open Shading Language (OSL), 66 bytes, A000201

    shader abc(int i=1, output float o=1){o=floor(i*((1+sqrt(5))/2));}
    

    Next Sequence

    Scott Milner

    Posted 2017-07-21T15:00:01.030

    Reputation: 1 806

    3

    93. Clojure, 35 bytes, A000093

    #(Math/floor (Math/sqrt (* % % %)))
    

    Try it online!

    Next Sequence

    Uriel

    Posted 2017-07-21T15:00:01.030

    Reputation: 11 708

    3

    98. Befunge-98 (PyFunge), 153 bytes, A001772

    &v >1 >1+:00g\%kvv>1\>1-\2*\:kvv
     #   vw\-1g00: < >$v ^       < $
    >0p^ >$01g1-:01v> #> > 1+vv-1*b<
    ^>1+01p         ^ ^:     <>0
                   >p  k^.@zz
    

    Try it online! The two zs after the @ are nop's that never get executed but I added in the make the bytecount correspond to an easier sequence. Becuase of what I think is a quirk of the interpreter and the fact that TIO doesn't provide a trailing newline, input needs to be given with a trailing space.

    Next sequence

    pppery

    Posted 2017-07-21T15:00:01.030

    Reputation: 3 987

    3

    100. Pyke, 20 bytes, A000030

    Yaay, the 100th answer! 0-indexed.

                      `h
    

    Try it online!

    Next Sequence.

    Mr. Xcoder

    Posted 2017-07-21T15:00:01.030

    Reputation: 39 774

    @StepHen EDIT Sorry, fixing – Mr. Xcoder – 2017-08-11T19:27:00.903

    @StepHen How is this 1-indexed? Inputting 0 gives 0 as it should – Business Cat – 2017-08-11T19:27:30.777

    @StepHen Fixed, haha – Mr. Xcoder – 2017-08-11T19:28:00.430

    3

    110. Nim, 442 bytes, A000081

    from strutils import parseint
    import math
    
    proc A000081(index: int): int =
     if index <= 0: return 0
     elif index <= 2: return 1
     elif index == 3: return 2
     elif index == 4: return 4
     else:
      var n: int = index - 1
      result = 0
      for k in 1..n:
       var t: int = 0
       for d in 1..k:
        if gcd(d,k)==d:
         t = t + (d * A000081(d))
       result = result + t*A000081(n-k+1)
      result = int(result / n)
     return
    
    echo A000081(parseint(readline(stdin)))
    

    Try it online!

    Next sequence

    KSmarts

    Posted 2017-07-21T15:00:01.030

    Reputation: 1 830

    3

    113. Arcyóu, 228 bytes, A000049

    (: grp (F(d) d))
    (: q (# (q)))
    (: t (? q (] 
     (r * (* (_ 2 3) q))) 2))
    (: a 0)
    (f x (_ 1 t) (grp
     (: b 0)
     (f y (_ t) (grp
      (f z (_ t) (grp
       (? (= (+ (* 3 (* y y)) (* 4 (* z z))) x) (: b 1) 1)
      ))
     ))
     (: a (+ a b))
    ))
    (p a)
    

    This is slow for terms past about the fifth, but Arcyóu is implemented in Python, which does support arbitrary precision numbers. Try it online!

    Next sequence (let's try some geometry ...)

    pppery

    Posted 2017-07-21T15:00:01.030

    Reputation: 3 987

    3The next one ought to be done in Hexagony. – KSmarts – 2017-08-16T15:41:00.760

    Does anyone have tips or pseudocode for the next sequence? Couldn't find anything specific on the OEIS. – NieDzejkob – 2017-08-16T18:31:23.667

    2why do you keep doing hard next-sequences ;_; xD – HyperNeutrino – 2017-08-16T20:09:05.507

    1Because I think this challenge is progressing too fast. Actually, this is only my second hard sequence, and the first one was accidental; I didn't realize it was going to be hard. – pppery – 2017-08-16T21:18:47.597

    This one isn't actually hard; just find a language with only 32 bit numbers and hardcode. – pppery – 2017-08-16T21:20:59.353

    1@ppperry FWIW I am strongly opposed to hardcoding anything that is computational :P and still, even if it's the second one it's still very very hard ._. – HyperNeutrino – 2017-08-16T22:08:48.447

    3

    I managed to decypher the name, I believe. It's about thr number of different "tetrominoes" with n pieces, but on a hexagonal grid. Read Polyhex on Wikipedia.

    – NieDzejkob – 2017-08-17T01:58:16.967

    2

    @NieDzejkob Your link was 404

    – HyperNeutrino – 2017-08-17T15:26:59.360

    @HyperNeutrino tfw you are too lazy to copy a link... I wonder what that /wiki/ part is for – NieDzejkob – 2017-08-17T20:34:40.957

    3

    122. MIT/GNU Scheme, 2057 bytes, A000525

    So I'm implementing A000081 again...

    (define (add f g)
      (stream-map + f g) )
    
    (define (scale c f)
      (stream-map (lambda (v) (* c v)) f) )
    
    (define (adddiag sf)
      (let ((f0 (stream-first sf)))
        (cons-stream (stream-first f0)
             (add (stream-rest f0) (adddiag (stream-rest sf))) ) ) )
    
    (define (mult f g)
      (adddiag (stream-map (lambda (v) (scale v g)) f)) )
    
    (define (prependzeros n f)
      (if (= 0 n) f (cons-stream 0 (prependzeros (-1+ n) f))) )
    
    (define (intersperse f n)
      (cons-stream (stream-first f)
               (prependzeros n (intersperse (stream-rest f) n)) ) )
    
    (define (iterate fun init)
      (cons-stream init (iterate fun (fun init))) )
    
    (define (from n)
      (cons-stream n (from (1+ n))) )
    
    (define (scanl fun init s)
      (cons-stream init (scanl fun (fun init (stream-first s)) (stream-rest s))) )
    
    (define (expx f)
      (cons-stream 1
               (adddiag (stream-map (lambda (s g) (scale (/ 1 s) g))
                        (scanl * 1 (from 2))
                        (iterate (lambda (g) (mult f g)) f) )) ) )
    
    (define (eu f)
      (expx (adddiag (stream-map (lambda (n) (scale (/ 1 n)
                                                    (intersperse f (-1+ n)) ))
                                 (from 1) ))) )
    
    (define gf000081s (cons-stream 1 (stream-rest (eu gf000081s))))
    
    (define gf000081 (cons-stream 0 gf000081s))
    
    (define (recip1 f)
      (let ((msf (scale -1 (stream-rest f))))
        (cons-stream 1 (adddiag (iterate (lambda (g) (mult msf g)) msf))) ) )
    
    (define (div1 f g)
      (mult f (recip1 g)) )
    
    (define (pow7 f)
      (let* ((p2 (mult f f))
             (p4 (mult p2 p2))
             (p6 (mult p4 p2)) )
        (mult p6 f) ) )
    
    (define (addconst c f)
      (cons-stream (+ c (stream-first f))
                   (stream-rest f) ) )
    
    (define gf
      (let* ((p2 (mult gf000081 gf000081))
             (p3 (mult p2 gf000081))
             (p4 (mult p3 gf000081)) )
        (div1 (mult p4 (addconst 64
                                 (add (add (scale -79 gf000081)
                                           (scale  36 p2) )
                                      (scale -6 p3) ) ))
              (pow7 (addconst 1 (scale -1 gf000081))) ) ) )
    
    (define (f n) (stream-ref gf (+ 4 n)))
    

    In debian, MIT/GNU Scheme is in the package mit-scheme.

    Here's how to use it when the program is in a file ps.scm:

    $ scheme --load ps.scm
    MIT/GNU Scheme running under GNU/Linux
    [...]
    1 ]=> (f 20)
    
    ;Value: 90039381031273
    

    Next sequence

    Christian Sievers

    Posted 2017-07-21T15:00:01.030

    Reputation: 6 366

    Man, I wanted to do this one. I mean, I implemented A000081 first...

    – KSmarts – 2017-09-01T15:38:02.257

    Sorry, I thought I had waited long enough... – Christian Sievers – 2017-09-01T16:46:45.903

    3

    130. TI-Nspire CAS Basic, 90 bytes, A000482

    Define f(n)=
    Prgm
    :Disp polyCoeffs(taylor((−ln(1-x))^(5),x,n),x)[1]*((n!)/(5!))
    :EndPrgm
    

    Next Sequence

    Code in Action

    Fun fact: I tried to implement 3 other sequences, but was too late as other answers had been made

    Husnain Raza

    Posted 2017-07-21T15:00:01.030

    Reputation: 329

    Pretty straightforward implementation from Oeis page, also hooray for first actual answer – Husnain Raza – 2017-09-02T19:16:23.123

    Also next sequence has closed form :o

    – Husnain Raza – 2017-09-02T20:18:11.293

    I know that feeling. I tried to implement 2 sequences, only the third got through. – NieDzejkob – 2017-09-02T20:32:43.013

    Next sequence is pretty straightforward – Husnain Raza – 2017-09-02T20:36:32.677

    Yeah, fractional factorials will take a while to figure out. – NieDzejkob – 2017-09-02T20:38:46.550

    Or do these square brackets mean "round"? There aren't any normal brackets inside them... – NieDzejkob – 2017-09-02T20:47:15.240

    square brackets are the floor function – Husnain Raza – 2017-09-02T20:59:36.833

    Duh, I should've read the notes at the top... – NieDzejkob – 2017-09-02T21:00:23.870

    Let us continue this discussion in chat.

    – Husnain Raza – 2017-09-02T22:06:07.007

    3

    134. Emoji, 277 bytes, A000643

    i
    0
    ⛽
    i1i1
    ⛽
    1⛽
    10
    ⛽
    2
    tt
    ➡
    

    Try it online!

    Next sequence!

    Explanation:

    In contrast to Emojicode, Emoji is an esoteric programming language. Emoji is similar to GolfScript and CJam in that it uses a stack as the primary memory.

    		Implicitly push all arguments as string. Stack: "7"
    		Floor. Normally  would be used to get a float, but using
    		floor gives an int, which (since the interpreter is written
    		in Python) is a bignum. Stack: 7
    i		Store to variable i. Stack:
    0		Push "0", to string, duplicate. Stack: a(1) a(0)
    ⛽...⛽...	While(...) do ... (let's look later in the loop)
    i		(in while condition) recall variable i. Stack: a(4) a(3) i
    		Duplicate. Stack: a(4) a(3) i i
    1		Subtract 1. Stack: a(4) a(3) i i-1
    i		Store i-1 to i for next iteration. Stack: a(4) a(3) i
    1		Is greater than 1? This means that the outer loop will be
    		repeated n - 1 times, where n is the input.
    		Stack: a(4) a(3) true
    1		(in outer loop) Now we will calculate 2^a(3) - push 1.
    		Stack: a(4) a(3) 1
    ⛽...⛽...	While(...) do ... (now a(3) is the loop counter, let's assume
    		we are at the last iteration of this loop.)
    		Swap. Stack: a(4) 2^(a(3)-1) 1
    		Duplicate. Stack: a(4) 2^(a(3)-1) 1 1
    1		Subtract 1. Stack: a(4) 2^(a(3)-1) 1 0
    		Swap. Stack: a(4) 2^(a(3)-1) 0 1
    0		Is greater than 0? This means that the inner loop will be
    		repeated a(3) times. Stack: a(4) 2^(a(3)-1) 0 true. Notice
    		that after true is popped, the two values are swapped compared
    		to the beginning of the condition evaluation. This has to be
    		fixed both in the inner loop and after it.
    		(in inner loop) swap. Stack: a(4) 0 2^(a(3)-1)
    2		Multiply by 2. Stack: a(4) 0 2^a(3).
    		The loop ends. Stack: a(4) 2^a(3) 0
    		The counter is now always 0 and has to be discarded. Since
    		there is no such instruction, an empty if is used instead.
    		Stack: a(4) 2^a(3)
    		Swap. Stack: 2^a(3) a(4)
    t		Duplicate and store a(4) in t. Stack: 2^a(3) a(4)
    		Add. Stack: a(5)
    t		Restore a(4) from variable. Stack: a(5) a(4).
    		The loop ends here. Stack: a(7) a(6).
    		Swap. Stack: a(6) a(7).
    ➡		Print a(7). The stack is discarded at the end of the program.
    

    Emoji aren't fixed-width in a fixed-width font, so spaces don't work for alignment. Fortunately, tabs work, but different emoji fonts might slightly break it.

    NieDzejkob

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 630

    ಠ_ಠ I have a feeling that you might get the bounty when it's finally awarded :P – caird coinheringaahing – 2017-09-04T09:58:02.603

    @cairdcoinheringaahing Unless someone posts an answer in Malbolge, a. k. a. you are probably right. Have you seen 99 bottles of beer in this? – NieDzejkob – 2017-09-04T10:50:44.983

    3

    143. Excel, 120 bytes, A000782

    =2*FACT(2*A1)/(FACT(A1)*(FACT(A1+1)))-IFERROR(FACT(2*A1-2)/(FACT(A1-1)*(FACT(A1))),0)                                   
    

    Next sequence!

    Input is in cell A1. It just implements the function listed on OEIS:

    a(n) = 2 * C(n) - C(n-1)
    C(n) = (2n)! / (n!(n+1)!)
    

    Technically, only n > 0 should be valid so the IFERROR bit could be dropped since it only errors on n < 1. I left it in for artistic license and to have what I think is a more interesting next sequence.

    Engineer Toast

    Posted 2017-07-21T15:00:01.030

    Reputation: 5 769

    3

    148. Python 2 (IronPython), 173 bytes, A000695

    def to_b_4(k):
     r=""
     while k>0:
      r=`k%4`+r
      k //=4
     return r
    n=input()
    i=j=b=0
    while i<=n:
     b=set(to_b_4(j))
     if not("2"in b or"3"in b or"4"in b):
      i+=1
     j+=1
    print(j-1)
    

    Try it online!

    Next Sequence

    Stephen

    Posted 2017-07-21T15:00:01.030

    Reputation: 12 293

    I'll tackle this with OCaml... – NieDzejkob – 2017-09-08T18:19:04.843

    3

    150. Julia 0.6, 125 bytes, A001993

    function A001993(n)
     m=zeros(15,15)
     for i=1:14
     m[i,i+1]=1
     end
     m[:,1]=[1;2;0;-2;-4;1;3;3;1;-4;-2;0;2;1;-1]
     (m^n)[1,1]
    end
    

    Next sequence

    Try it online!

    The next one is easy, and all languages are back on the table, so somebody may have to re-work the stack snippet to allow for multiple uses (I don't know enough javascript to tell if that's already there or not).

    Implements the matrix product formula given in the OEIS page. It was pretty fun learning a bit of Julia; it's quite similar to Matlab.

    Giuseppe

    Posted 2017-07-21T15:00:01.030

    Reputation: 21 077

    Yay more Python :D :D :D – HyperNeutrino – 2017-09-11T15:05:55.113

    2I've also had a bit of fun learning new languages for this challenge. Except for INTERCAL. – KSmarts – 2017-09-11T17:33:08.590

    @KSmarts You have been warned. By your own program. – NieDzejkob – 2017-09-11T17:39:24.290

    3

    154. Verilog, 262 bytes, A001344

    module OEIS1344 (input c, input [99:0] n, output reg [99:0] r=0, output reg v=1'b1);
    reg [99:0] i,f;
    always @ (posedge c) if(v)begin f=n-((n>0)?1:0);v=(f==0);i=f-1;r=(n*(n+3))+((n==0)?2:1);end else begin v=(i==0)||(i==-1);f=v?f:f*i;i=i-1;r=v?r*f:r;end 
    endmodule
    

    Next sequence!

    The Verilog module above calculates OEIS A001344.

    The code below is the same code but prettified, and a testbench module added to allow you to run the code in a Verilog simulator such as modelsim.

    I have verified inputs up to the 22nd element in the sequence, beyond which OEIS runs out of examples, and shortly afterwards the numbers start overflowing 100bit arithmetic. I believe that is allowed as per the rules about assuming input and output numbers will never overflow the language. Originally I had used 32bit arithmetic which caused overflow at 13, but without changing the byte count (just 3 numbers from 31 to 99) we can get up to 22-ish.

    When simulating, the input number is clocked in on the rising edge. v may go low if it is going to take more than one clock cycle to calculate. Once v is high after the clock edge that loaded the number, the output r can be considered a valid number of the OEIS A001344 sequence.

    The code is actually making use of the related OEIS sequence, A028387 which calculates n + (n+1)^2. By multiplying the n+1'th element of that sequence by n! we arrive at the A001344 sequence. All that is required is a little fiddling around with the value of n to make it 0-indexed as per the requirements and we have our result.

    To do this in Verilog is a little bit of a pain as it requires a factorial. The simplest approach is to use an iterative approach over n clock cycles to calculate the factorial and output the final result.

    I should probably point out that both the OEIS1344 module and its testbench are very naïve approaches to get the job done. But since joining PPCG I've wanted to be able to use Verilog in an answer, and I found a way to shoehorn it into this one.


    The following is an example output from ModelSim:

    Testbench Output Example

    The following is the testbench code:

    module OEIS1344_test;
    
    reg c = 0;
    always begin
        #10 c = !c;
    end
    
    reg  [99:0] n;
    wire [99:0] r;
    wire v;
    
    OEIS1344 dut (
        .c(c),
        .n(n),
        .r(r),
        .v(v)
    );
    
    reg  [99:0] i;
    initial begin
        for (i = 0; i < 23; i=i+1) begin
            n = i;
            @(posedge c);
            while (!v) @(posedge c);
        end
    end
    
    endmodule
    
    module OEIS1344 (
        input c,
        input [99:0] n,
        output reg [99:0] r = 0,
        output reg v = 1'b1
    );
    
    reg [99:0] i,f;
    always @ (posedge c) begin
        if (v) begin
            f = n - ((n > 0) ? 1 : 0);
            v = (f == 0);
            i = f - 1;
            r = (n * (n + 3)) + ((n == 0) ? 2 : 1);
        end else begin
            v = (i == 0) || (i == -1);
            f = v ? f : f * i;
            i = i - 1;
            r = v ? r * f : r;
        end
    end
    endmodule
    

    Tom Carpenter

    Posted 2017-07-21T15:00:01.030

    Reputation: 3 990

    3

    160. Bash, 315 bytes, A000778

    #!/bin/bash
    
    array=()
    array[0]=1
    i=1
    read n
    
    while [ $i -le $(expr 2 * $n + 2) ]
    do
        let array[$i]=array[$(expr $i - 1)]*$i
        let i=i+1
    done
    
    echo $(expr ${array[$(expr 2 * $n)]} / ${array[$n]} / ${array[$(expr $n + 1)]} + ${array[$(expr 2 * $n + 2)]} / ${array[$(expr $n + 1)]} / ${array[$(expr $n + 2)]} - 1)
    

    Try it online!

    A000315

    irapsaged

    Posted 2017-07-21T15:00:01.030

    Reputation: 137

    It'll take a moment to figure this out, but I can already see that this is related to sudoku. – NieDzejkob – 2017-09-19T10:34:06.050

    3

    166. Scratch 2, 638 bytes, A000114

    code as image

    Or, when written as text in the ScratchBlocks2 format:

    when green flag clicked
    ask [] and wait
    set [a v] to ((answer) + (2))
    if <(a) = [2]> then 
      say [3]
    else 
      set [b v] to (((a) * (a)) / (2))
      set [d v] to [2]
      repeat until <(d) = (a)> 
        if <((a) mod (d)) = [0]> then 
          set [c v] to [2]
          set [prime v] to [1]
          repeat until <<(prime) = [0]> or <(c) > ([sqrt v] of (d))>> 
            if <((d) mod (c)) = [0]> then 
              set [prime v] to [0]
            end
            set [c v] to ((c) + (1))
          end
          if <(prime) = [1]> then 
            set [b v] to ((b) * ((1) - ((1) / ((d) * (d)))))
          end
        end
        set [d v] to ((d) + (1))
      end
      say ((b) - ((b) mod (1)))
    end
    

    Next sequence

    pppery

    Posted 2017-07-21T15:00:01.030

    Reputation: 3 987

    2Note for next sequence: as with previous similar sequences, you cannot hardcode. You must compute, since it has to theoretically work for ns up to 1000. – Stephen – 2017-09-19T21:02:10.913

    Can we hardcore sequences if we have to? – Husnain Raza – 2017-09-19T23:16:51.097

    1

    Also good resource for future things http://vixra.org/abs/1409.0048

    – Husnain Raza – 2017-09-19T23:30:43.337

    @HusnainRaza If you can somehow get a 1000 values of the next sequence, sure. – totallyhuman – 2017-09-19T23:36:03.120

    The next sequence is a programmer's nightmare in terms of documentation... – totallyhuman – 2017-09-20T00:06:18.380

    what documentation – Husnain Raza – 2017-09-20T00:22:04.313

    Well, a week of waiting yet again... – NieDzejkob – 2017-09-20T08:43:25.943

    1When everyone gives up we can always "use" Magma (totally no copy-paste from OEIS) – Grzegorz Puławski – 2017-09-20T12:07:30.170

    1@GrzegorzPuławski alernatively, we can reverse engineer Magma and copy the necessary functions to some other language – NieDzejkob – 2017-09-20T12:53:43.980

    @NieDzejkob oh that sounds much more fun – Grzegorz Puławski – 2017-09-20T12:55:34.907

    @HusnainRaza yes, you can hardcode, *iff* your program works for the first 1000 entries. – Stephen – 2017-09-20T12:59:06.487

    1I wonder, if I got another function in Magma other than SubgroupLatices() that produces the same sequence, would that still be considered copy from OEIS? (after packaging into a function) – Grzegorz Puławski – 2017-09-20T13:50:47.847

    Magma is proprietary, so there's now way of finding out the innards of the function... – totallyhuman – 2017-09-20T23:27:19.813

    @ppperry how do you convert the block format into the text format? I have the next sequence in Scratch 2 but I don't know how to get it in text – dylnan – 2017-12-25T18:58:02.010

    I've forgotten how I posted this, actually. – pppery – 2017-12-25T21:08:59.330

    3

    167. Magma, 101 bytes, A000638

    a000638:=function(n);if n eq 0 then return 1;else return#SubgroupClasses(Sym(n));end if;end function;
    

    Next sequence

    You're probably thinking "This is taken from the OEIS site!", but hold on. While checking Magma documentation, I found something interesting here. One of OEIS descriptions of this sequence is number of conjugacy classes of subgroups of symmetric group S_n, and the documentation speaks of a build-in! And it's a different one than the one used on OEIS SubgroupLattice(), this one is SubgroupClasses(). So it happens that both functions create the same amount of subgroups (possibly how the math of this works - I'm not sure), but SubgroupClasses() is actually THE correct way. Thus I felt that this answer is eligible.

    You can try it here

    Code usage:

    Just paste the function and then call it by a000638(5); or any other number instead of 5 (note, anything higher than 11 will time out). You can also use this to output 11 first integers in the sequence:

    for i := 0 to 10 by 1 do a000638(i); end for;
    

    Code explanation:

    a000638 := function(n);           // Create a function taking one argument
        if n eq 0 then                // If argument is 0
            return 1;                 //     Then return 1
        else                          // Otherwise
            return #                  //     Count and return the number of
                   SubgroupClasses(   //         Conjugacy classes of subgroups of
                       Sym(n)         //             Symmetric group of order n
                   );
        end if;
    end function;
    

    Grzegorz Puławski

    Posted 2017-07-21T15:00:01.030

    Reputation: 781

    3

    171. TrumpScript, 541 bytes, A000204

    Putin hears all your life
    Putin is safe because its Putin
    Trump is, 1000001 minus 1000000; great
    Our beautiful America is, 1000003 minus 1000000; the greatest
    Of course everything is, Trump plus Trump;
    Every million is for Trump;
    If you want, Putin is Trump?;:
    Say Putin!
    Otherwise: if for you, Putin is Everything?;:
    Say America!
    Otherwise:
    Money is Everything
    As long as, our Money less than Putin;:
    Russia is America
    America is, Trump plus America;
    Trump is Russia
    Money is, Money plus Million;!
    Say America with force!!
    America is great.
    

    Try it online!

    Next sequence

    Pseudocode for explanation:

    var Putin = int(input())
    var Trump = 1
    var America = 3
    var Everything = Trump + Trump
    var Million = Trump
    if(Putin == Trump)
        print(Putin)
    else if(Putin == Everything)
        print(America)
    else
        var Money = Everything
        while(Money < Putin)
            var Russia = America
            America = Trump + America
            Trump = Russia
            Money = Money + Million
        print(America)
    America is great.
    

    Grzegorz Puławski

    Posted 2017-07-21T15:00:01.030

    Reputation: 781

    3

    190. COBOL (GNU), 725 bytes, A001182

           IDENTIFICATION DIVISION.
           PROGRAM-ID.  A001182.
           AUTHOR.  KSmarts.
    
           DATA DIVISION.
    
           WORKING-STORAGE SECTION.
           01  Num1                                PIC 999   VALUE ZEROS.
           01  Num2                                PIC 999   VALUE ZEROS.
           01  Iterator                            PIC 999   VALUE ZEROS.
           01  Result                              PIC 9(6)  VALUE ZEROS.
    
           PROCEDURE DIVISION.
    
           ACCEPT Num1.
           MOVE Num1 TO Iterator
           ADD 1 TO Num1
           MOVE 1 TO Num2
           PERFORM Summing Iterator TIMES
           DISPLAY Result.
           STOP RUN.
    
           Summing.
               COMPUTE Result = Result + (Num1**2 - Num2**2)**.5
               ADD 1 TO Num2.
    
    

    Next Sequence

    Try it online!

    COBOL was originally designed with ease-of-use as the goal. We've come a long way since then.

    KSmarts

    Posted 2017-07-21T15:00:01.030

    Reputation: 1 830

    1

    Does anybody know what the symbols in the rightmost column of the table here mean? 'Cause A000722 is easy to solve but I don't know how to narrow it down to A000725...

    – totallyhuman – 2017-09-27T15:56:53.033

    1@icrieverytim I think it's the same as the comments: Equivalence classes "under action of permutation of variables on the domain and permutation and complementation of the range." – KSmarts – 2017-09-27T16:35:31.523

    1Why are there like three different sequences around the next one with the exact same description? – Husnain Raza – 2017-09-28T03:34:32.657

    1@HusnainRaza They all have the same title, but different descriptions in the comments. It looks like they are equivalence classes under different transformations – KSmarts – 2017-09-28T13:42:52.757

    Is this impossible – Husnain Raza – 2017-09-29T03:25:16.033

    3

    195. ><>, 210 bytes, A000589

    5+::6+}2*}5 -{2[\]b*$,n;
    //?={:{:/?= 0:  /
    :\      >    ~~1v
    \{:}-12[v   /~]{ 22[v/~]*$32[v
    v       <           <        >
                /:2=    ?/\
                ?
    >:?\~11>*l2\
    -1:/ v$\?- /
         >  :1) ^   v,$]~ /
    

    Try it here - input given as initial stack
    Next sequence

    Fixed previous version. Byte count changed so I decided to delete and repost.
    For some reason, doesn't work on TIO.

    The code has 3 parts:
    enter image description here
    Red - computing main sequence;
    Orange - computing binomial using factorial;
    Blue - computing factorial;

    Grzegorz Puławski

    Posted 2017-07-21T15:00:01.030

    Reputation: 781

    3

    196. Java (OpenJDK 9), 56 bytes, A000210

    int f(int n) {return (int)Math.floor((n+1)*(Math.E-1));}
    

    Try it online!

    Next Sequence

    Stephen

    Posted 2017-07-21T15:00:01.030

    Reputation: 12 293

    Not like it matters very much, but I think you should say this is Java 9. – NieDzejkob – 2017-10-02T18:41:17.050

    @NieDzejkob EDIT oh I thought that Java 9 was all taken and that Java 8 was still available mb – Stephen – 2017-10-02T18:50:42.453

    3

    200. shortC, 189 bytes, A000092

    Note: byte count includes the +3 bytes for -lm.

    f(x){Lr=0,d=0,n=1;O;d<x+1;n++){Lc=0,m=ceil(sqrt(n))+1,i=-m,j,k;O;i<m;i++)Oj=-m;j<m;j++)Ok=-m;k<m;k++)c+=i*i+j*j+k*k<=n;c-=lround(sqrt(n*n*n)*4.18879020478639);c=abs(c);Fc>r)d++,r=c;}Tn-1
    

    Try it online!

    Next sequence!

    Yay, 200th answer.

    NieDzejkob

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 630

    For the next sequence, x < n (modulo implies it but it wasn't immediately obvious to me). – NieDzejkob – 2017-10-02T21:37:18.620

    1Well, that's 200. I'm not sure whether to be glad or astounded that anyone still cares about this challenge :P – caird coinheringaahing – 2017-10-02T21:51:14.417

    @cairdcoinheringaahing that means that you came up with an interesting challenge. You should be proud. – NieDzejkob – 2017-10-03T10:31:12.800

    3

    201. Nim, 213 bytes, A000189

    from strutils import parseint
    import math
    
    proc A000189(index: int): int =
      result=1
      for x in 1..index-1:
        if x^3 mod index == 0:
          result = result + 1
      return
    
    echo A000189(parseint(readline(stdin))+1)
    

    Try it online!

    Next Sequence.

    KSmarts

    Posted 2017-07-21T15:00:01.030

    Reputation: 1 830

    Darn I had a Brain-Flak solution coming :P Oh well it was nowhere near done anyway xD – HyperNeutrino – 2017-10-02T22:58:34.290

    3

    204. Positron, 53 bytes, A000096

    f = function {
          return ( $1 * ( $1 + 3 ) ) / 2
    }
    

    Try it online!

    Next Sequence

    shout out to all the New Yorkers here! xD

    N.B. The next one can be hardcoded because it is a finite sequence

    HyperNeutrino

    Posted 2017-07-21T15:00:01.030

    Reputation: 26 575

    I'm a new yorker :D – Giuseppe – 2017-10-02T23:30:27.773

    Is there a Mathematica built-in for the next one? – KSmarts – 2017-10-02T23:33:33.083

    @KSmarts TrackStops@"NewYorkBroadway" (jk idk but I wouldn't be surprsed :P) – HyperNeutrino – 2017-10-02T23:35:03.170

    If I find the Mathematica built-in, would you guys be okay with me using Mathematica for this? :P – totallyhuman – 2017-10-03T00:58:47.683

    @icrieverytim no – HyperNeutrino – 2017-10-03T00:59:05.967

    1I'm afraid we might need you to save the challenge again... – NieDzejkob – 2017-10-08T11:18:13.423

    3

    208. Befunge 93, 75 bytes, A000389

    &:5-v
    vp00<v`g00<
        v_:v
        >1 >/v:
    >:1-:v v*<^_$5432***/.@
    ^    _$> \:^
    

    Try it online!

    Next sequence

    Since it has been pointed out that MATLAB might be is overkill for such a simple sequence I decided to give Befunge a try, and free MATLAB for future use.

    Hoping it's not against the rules I'm changing the language of my answer maintaining the same bytecount.

    Cinaski

    Posted 2017-07-21T15:00:01.030

    Reputation: 1 588

    1You used MATLAB for a sequence that could've been done in 23 bytes of Befunge. I think that's a little bit wasteful. – NieDzejkob – 2017-10-10T10:27:20.947

    @NieDzejkob Erik using jelly for 2,0,0,0,0,0,0... though xD also i cri everytim using all the pythons lol – HyperNeutrino – 2017-10-10T11:59:32.360

    @HyperNeutrino LOL, right. BTW, I managed to golf it down to 21 while just thinking about it instead of listening to the history teacher. – NieDzejkob – 2017-10-10T12:15:37.750

    @NieDzejkob Remember that this is not code-golf.. And also that your bytecount must be unique so 21 and 23 bytes answer are not valid at this point. – Cinaski – 2017-10-10T12:19:55.500

    1@Cinaski The point is that using such a useful language for something trivial enough to be solved in a short Befunge program is wasteful of MATLAB. – HyperNeutrino – 2017-10-10T12:24:13.197

    1@HyperNeutrino the point is to starve useful languages off in trivial sequences so people have to use languages no one has ever heard of in the last 15 or so, which is fun :P – Stephen – 2017-10-10T15:47:13.053

    @Stephen given Hyper's had to save the challenge twice now, I think he'd prefer to have all the easy ones ready for any really difficult sequences :P – caird coinheringaahing – 2017-10-10T16:06:13.143

    @Stephen If Proton didn't exist, the challenge would have died because I couldn't have solved it in anything. I mean, KSmarts did get a (possibly working) Mathematica answer, but still... Without Python, this challenge would have died 3 times by now ._. – HyperNeutrino – 2017-10-10T16:15:41.303

    @HyperNeutrino the problem is not that there aren't enough languages, but that there aren't enough languages with builtin, easy-to-use arbitrary-precision integers. – Stephen – 2017-10-10T16:43:23.223

    @Stephen That's true; mainly the thing is though that I don't know many languages to save the challenge so unless other people help with that the challenge would die lol – HyperNeutrino – 2017-10-10T17:39:05.327

    @NieDzejkob If you don't mind to share I'm really curious to see your 21bytes solution. It was my first time with Befunge and it was quite challenging for me to golf this from ~140bytes (of the first working solution) to 75. – Cinaski – 2017-10-11T13:30:43.257

    @Cinaski Sure. &:1-:1-:1-:1-3k*'x/.@ – NieDzejkob – 2017-10-11T14:55:41.513

    @Stephen It's really frustrating when I'm working on a solution to a simple sequence in a more difficult-to-use language and someone beats me with something more practical, though. – KSmarts – 2017-10-11T15:32:53.607

    1@KSmarts, it's even more frustrating when people change history unnecessarily. IMO the edit to change the language is against the spirit of [tag:answer-chaining], and OP should revert it. Also, everyone should stop complaining when someone else uses a language they wanted, or leaves a next sequence they don't like. The challenge is designed to die. If you don't like it, don't play. – Peter Taylor – 2017-10-11T18:02:28.697

    3

    210. Pyth, 76 bytes, A000100

     "This is dummy text. Can be replaced with whatever you want!"l{s.pMfq3eST./
    

    See the first few terms.

    Next Sequence.

    Explanation

    • (leading space) : Makes the interpreter ignore the next command.

    • "This is dummy text.... !" : Pushes a dummy String, which is ignored.

    • l{s.pMfq3eST./ : The thing which does the actual job.

      ./     @ Integer partitions.
      fq3eST @ Filter the partitions with maximal integer `3`.
      .pM    @ Get all the permutations of each.
      s      @ Flattens.
      {      @ Deduplicate.
      l      @ Length.
      

    Mr. Xcoder

    Posted 2017-07-21T15:00:01.030

    Reputation: 39 774

    lol the next sequence is almost the same as the previous :P – Uriel – 2017-10-10T13:02:49.433

    3

    211. 05AB1E, 78 bytes, A000076

    2sm©ÝDâεDDн2m4*sP4*+sθ2m5*+}Ùʒ®›1s-}gqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq
    

    Try it online!

    Explanation

    2sm©ÝDâεDDн2m4*sP4*+sθ2m5*+}Ùʒ®›1s-}gqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq  5
    2                                                                               5, 2
     s                                                                              2, 5
      m                                                                             32
       ©                                                                            32 [Copy to register]
        Ý                                                                           [0, ..., 32]
         D                                                                          [0, ..., 32], [0, ..., 32]
          â                                                                         [[0, 0], [0, 1], ..., [32, 31], [32, 32]]
           ε                   }                                                    For each pair [x, y]
            D                                                                       [x, y], [x, y]
             D                                                                      [x, y], [x, y], [x, y] # yes I realize I can triplicate
              н                                                                     [x, y], [x, y], x
               2                                                                    [x, y], [x, y], x, 2
                m                                                                   [x, y], [x, y], x^2
                 4                                                                  [x, y], [x, y], x^2, 4
                  *                                                                 [x, y], [x, y], 4x^2
                   s                                                                [x, y], 4x^2, [x, y]
                    P                                                               [x, y], 4x^2, xy
                     4                                                              [x, y], 4x^2, xy, 4
                      *                                                             [x, y], 4x^2, 4xy
                       +                                                            [x, y], 4x^2+4xy
                        s                                                           4x^2+4xy, [x, y]
                         θ                                                          4x^2+4xy, y
                          2                                                         4x^2+4xy, y, 2
                           m                                                        4x^2+4xy, y^2
                            5                                                       4x^2+4xy, y^2, 5
                             *                                                      4x^2+4xy, 5y^2
                              +                                                     4x^2+4xy+5y^2
                                Ù                                                   Now we have a list of all numbers formed by this; uniquify
                                 ʒ     }                                            Keep numbers `n` where the result of the codeblock is 1
                                  ®                                                 n, 32
                                   ›                                                n > 32
                                    1                                               n > 32, 1
                                     s                                              1, n > 32
                                      -                                             1 - (n > 32)
                                        g                                           Length; final number of numbers formed
                                         qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq  `q` terminates the program
    

    Next Sequence

    HyperNeutrino

    Posted 2017-07-21T15:00:01.030

    Reputation: 26 575

    wait, x to the power y is m in 05AB1E? Why? – caird coinheringaahing – 2017-10-10T19:45:28.327

    @cairdcoinheringaahing – totallyhuman – 2017-10-10T21:16:38.110

    @icrieverytim yeah? What? – caird coinheringaahing – 2017-10-10T21:18:25.953

    @cairdcoinheringaahing Good question. I don't know either lol – HyperNeutrino – 2017-10-10T23:28:44.277

    3

    217. Mathematica, 174 bytes, A000411

    L[a_, s_] := Sum[JacobiSymbol[-a, 2k + 1] / (2k + 1)^s, {k, 0, Infinity}]
    d[a_, n_] := L[-a, 2n] * (2a / Pi)^(2n) / Sqrt[a] * (2n - 1)!
    A000411[n_] := Round @ N @ d[6, n + 1]
    

    Try it online!

    Next sequence.

    Note that this takes 30 seconds for n = 2 on TIO. Paper that was both useful and useless at the same time.

    totallyhuman

    Posted 2017-07-21T15:00:01.030

    Reputation: 15 378

    I found that paper very useful in creating the solution that I just now finished, more than 20 minutes late. It defines a recursive relationship, so you don't have to use infinite sums or Jacobi symbols at all. I'll have to save it in case another "Generalized Triangular Numbers" sequence comes up. – KSmarts – 2017-10-10T18:12:37.567

    Might want to add a version number – Stephen – 2017-10-10T18:19:13.743

    Rather than struggling with the paper you could just have looked at my Python code on OEIS.

    – Peter Taylor – 2017-10-10T19:18:45.033

    @PeterTaylor Unfortunately all versions of Python have been used (cough i cri everytim) – HyperNeutrino – 2017-10-10T20:06:38.097

    (though actually the logic there would've been really helpful nvm) – HyperNeutrino – 2017-10-10T20:06:55.047

    @Stephen Wait, why? – totallyhuman – 2017-10-10T20:07:32.337

    brackets fixed :P – HyperNeutrino – 2017-10-10T20:08:32.020

    @PeterTaylor ...I was not clever enough to look at the other sequences relevant to this one. >.< – totallyhuman – 2017-10-10T20:08:50.920

    @HyperNeutrino no they aren't – totallyhuman – 2017-10-10T20:10:24.933

    o wtf I tried lol – HyperNeutrino – 2017-10-10T20:10:41.217

    @KSmarts You and I see the paper very differently. :P In any case, sorry for ninja'ing you twice. Please find another opportunity for using Funciton, it's a really cool language. – totallyhuman – 2017-10-10T20:16:44.930

    @icrieverytim so other people can use other Mathematica versions – Stephen – 2017-10-10T21:43:33.437

    3

    218. ExtraC, 702 bytes, A000174

    long N be readint
    long R be 0
    for(long A be 0 AND not(A times A greater N) AND increment A)do
      for(long B be A AND not(A times A plus B times B greater N) AND increment B)do
        for(long C be B AND not(A times A plus B times B plus C times C greater N) AND increment C)do
          for(long D be C AND not(A times A plus B times B plus C times C plus D times D greater N) AND increment D)do
            for(long E be D AND not(A times A plus B times B plus C times C plus D times D plus E times E greater N) AND increment E)do
              if(A times A plus B times B plus C times C plus D times D plus E times E equals N)do
                increment R
              end
            end
          end
        end
      end
    end
    
    print(R)
    

    Try it online!

    Next sequence!

    NieDzejkob

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 630

    Oh god this verbosity – HyperNeutrino – 2017-10-11T13:39:23.163

    BTW, I think sorta(less) is supposed to work as <=, but it doesn't, so I had to use not(... greater ...). Also, I didn't bother removing the repeating expressions, because I would rather have simplicity and this is not codegolf. – NieDzejkob – 2017-10-11T14:45:45.627

    3

    221. Pony, 670 bytes, A000107

    fun b(n: U128): U128 =>
      if n == 0 then
        return 0
      elseif n == 1 then
        return 1
      else
        var result: U128 = 0
        var j: U128 = 1
        
        while j < n do
          var d: U128 = 1
          var t: U128 = 0
          while d <= j do
            if (j % d) == 0 then
              t = t + (d * b(d))
            end
            d = d+1
          end
          result = result + (t * b(n-j))
          j = j+1
        end
        return result / (n-1)
      end
    
    fun a(n: U128): U128 =>
      if n == 0 then
        return 0
      elseif n == 1 then
        return 1
      else
        var result: U128 = 0
        var i: U128 = 1
        while i < n do
          result = result + (a(n-i) * b(i))
          i = i+1
        end
        return result + b(n)
      end
    
    

    Next Sequence

    Try it online!

    KSmarts

    Posted 2017-07-21T15:00:01.030

    Reputation: 1 830

    I wouldn't have waited much longer before sending a boring variation of No. 122 as solution

    – Christian Sievers – 2017-10-11T20:39:16.707

    next sequence is also known as Ordered Bell Numbers – Giuseppe – 2017-10-11T20:57:07.977

    3

    223. GolfScript, 88 bytes, A000110

    {
     # Recurrence a(n+1) = sum a(k) * binomial(n, k)
     [1]{..,({[.(;\);]zip{~+}%}*+}@*-1=
    }
    

    Online demo

    Next sequence

    Peter Taylor

    Posted 2017-07-21T15:00:01.030

    Reputation: 41 901

    Does anyone have an idea what the O(...) mean in the first two formulas for the next seq? – NieDzejkob – 2017-10-12T07:50:18.613

    @NieDzejkob Big O notation

    – Christian Sievers – 2017-10-12T09:41:38.383

    @ChristianSievers have you seen that formula? The Big O notation is used for describing computational complexity, this was in the middle of a formula, which would obviously make no sense. – NieDzejkob – 2017-10-12T10:42:21.853

    1@NieDzejkob See the introduction and the section "Matters of notation"/"Other arithmetic operators" in the wikipedia article. It means there is a missing term of order O(...). – Christian Sievers – 2017-10-12T11:10:16.917

    @ChristianSievers Oh that's right, sorry. That would also mean the formula is not usable for computing the sequence. Not that it matters anymore. – NieDzejkob – 2017-10-12T13:34:14.590

    3

    224. Racket, 1232 bytes, A000088

    #lang racket
    
    (define (partsm n m)
      (if (= n 0)
          '(())
          (for*/list ([k (range 1 (add1 (min n m)))]
                      [r (partsm (- n k) k)] )
            (cons k r) ) ) )
    
    (define (parts n)
      (partsm n n) )
    
    (define (fact n)
      (for/product ([i (range 1 (add1 n))]) i) )
    
    (define (c2 n) ; ways to choose 2 elements from n
      (* n (sub1 n) 1/2) )
    
    (define (cycHash cl)
      (let ([h (make-hash)])
         (for ([i cl])
           (hash-update! h i add1 0) )
       h ) )
    
    (define (halfes ch)
      (for/hash ([(l m) ch]
                 #:when (even? l) )
        (values (/ l 2) m) ) )
    
    (define (centralizerSize ch)
      (for/product ([(l m) ch])
        (* (expt l m) (fact m)) ) )
    
    (define (fixp ch n)
      (for/sum ([(l m) ch]
                #:when (= (remainder n l) 0) )
        (* l m) ) )
    
    (define (s2orb hch n)
      (for/sum ([(hl m) hch]
                #:when (let-values ([(q r) (quotient/remainder n hl)])
                         (and (= 0 r) (odd? q)) ) )
        (* hl m) ) )
    
    (define (edgeOrbs ch)
      (let* ([hch (halfes ch)]
             [order (apply lcm (hash-keys ch))])
        (/ (for/sum ([k order])
             (+ (c2 (fixp ch k)) (s2orb hch k)) )
           order ) ) )
    
    (define (f n)
      (for/sum ([ch (map cycHash (parts n))])
        (/ (expt 2 (edgeOrbs ch)) (centralizerSize ch)) ) )
    

    Try it online!

    Next sequence

    Yes, it was Burnside's lemma time again! Symmetric group acts on n nodes, inducing an action on the possible edges and on the possible graphs. Count the orbits of the last action, yada yada. Run through the elements by conjugacy classes represented by partitions of n. Number of graphs fixed by an element g is 2 to the number of orbits of edges under the action of the cyclic group generated by g. So use Burnside's lemma again and find the number of edges fixed by each g^k. An edge is fixed if its endpoints are on fixed points or on points that are interchanged by the group element. Feel free to ask for more details!

    Christian Sievers

    Posted 2017-07-21T15:00:01.030

    Reputation: 6 366

    3

    227. C++ (clang), 861 bytes, A004903

    Thanks to user202729 for C++ help :)

    # include <iostream>
    # include <algorithm>
    # include <vector>
    # include <math.h>
    
    std::vector<int> getsums(std::vector<int> values, int times) {
    	if (times == 1) {
    		return values;
    	} else {
    		std::vector<int> results;
    		for (int i = 0; i < values.size(); i++) {
    			std::vector<int> subs = getsums(values, times - 1);
    			for (int j = 0; j < subs.size(); j++) {
    				results.push_back(subs[j] + values[i]);
    			}
    		} return results;
    	}
    }
    
    // This method is O(log_8(n)) I think.
    
    int main() {
    	int input; std::cin >> input;
    	int size = (int) pow(input / 8, 0.1) + 1;
    	std::vector<int> values;
    	for (int i = 0; i <= size; i++) values.push_back(pow(i, 10));
    	std::vector<int> sums = getsums(values, 8);
    	std:sort(sums.begin(), sums.end());
    	sums.erase(std::unique(sums.begin(), sums.end()), sums.end());
    	for (int i = 0; i < input; i++) std::cout << sums[i] << " ";
    }
    

    Try it online!

    My first C++ program that actually does something interesting \o/

    Next Sequence

    HyperNeutrino

    Posted 2017-07-21T15:00:01.030

    Reputation: 26 575

    very nice. I picked Gaia at random from TIO and saw your solution right as I was wrapping up! 4…10*¦8*Σ¦uȯ= if anyone is interested. – Giuseppe – 2017-10-18T17:17:54.957

    note that y is not a vowel for the next sequence (otherwise 20 would be in it) – Giuseppe – 2017-10-18T17:18:41.377

    @Giuseppe Cool, nice answer! Sorry for ninja'ing you haha – HyperNeutrino – 2017-10-18T17:18:46.477

    If A000086 shows up, I'd be glad if ninjas let me post my Shakespeare-esque masterpiece. – NieDzejkob – 2017-10-18T17:20:27.043

    @NieDzejkob Quick, now's your chance! – HyperNeutrino – 2017-10-20T14:48:38.970

    3

    228. Hodor, 361 bytes, A000861

    HoDoRHoDoR HODOR 000861(HODOR? ) {
      $HODOR: Hodor? = 0;
      $HODOR: HODOR?! = 0;
      hodor............ (Hodor? < HODOR? ) {
        HODOR?! = HODOR?! +1;
        $HODOR: d = HODOR?! % 10;
        $HODOR: h = HODOR?! % 100;
        HOdor!!! ( h==12 || ((h>20 || h<10) && ((d==1) || (d==2) || (d==3) || (d==5) || (d==9)))) {
          Hodor? = Hodor? +1;
        }
      }
      HODOR:: HODOR?! ;
    }
    

    Next Sequence

    Hodor!

    KSmarts

    Posted 2017-07-21T15:00:01.030

    Reputation: 1 830

    NOOOO.... I was ninja'd.... – Mr. Xcoder – 2017-10-18T17:37:28.530

    @Mr.Xcoder Hodor. – KSmarts – 2017-10-18T17:38:10.030

    @Mr.Xcoder same rip – Stephen – 2017-10-18T17:38:42.470

    1If you read the title of the next sequence out loud, I'd assume you're having a stroke.... – Grzegorz Puławski – 2017-10-18T20:06:18.357

    3

    237. M, 89 bytes, A000341

    ‘ḤŒ!s€2Ṣ€Ṣ$€QS€ÆPa/$$ÐfL                                                                 
    

    Try it online!

    Explanation

    ‘ḤŒ!s€2Ṣ€Ṣ$€QS€ÆPa/$$ÐfL  Main Link
    ‘                         Increment (for 0-indexing)
     Ḥ                        Double
      Œ!                      All permutations of {1 .. 2n} (implicit range)
        s€2                   Slice each permutation into subslices of length 2
              $€              For each subconfiguration
           Ṣ€                 Sort each pair
             Ṣ                Then sort the entire thing
                Q             Then remove duplicates
                       $$Ðf   Filter pairings using the last three links as a condition
                     a/       All (reduce over logical AND because M doesn't have the ALL builtin)
                 S€           Sums
                   ÆP         Are Prime
                           L  How many pairings are there?
    

    There are a bunch of spaces at the end

    Next Sequence

    HyperNeutrino

    Posted 2017-07-21T15:00:01.030

    Reputation: 26 575

    Does M not have an identity function? – caird coinheringaahing – 2017-10-27T14:15:02.150

    @cairdcoinheringaahing Maybe it does but spaces are better because they don't clutter the end – HyperNeutrino – 2017-10-27T14:15:59.963

    I'd say that you add those spaces to avoid A000087.

    – user202729 – 2017-10-27T14:25:38.303

    @user202729 A87 is at the edge of feasibility in Shakespeare. – NieDzejkob – 2017-10-27T14:27:53.493

    @user202729 I chose 89 because it looked nicer lol. Sometimes I decide to be nicer and sometimes I decide to make it a bit more challenging. In this case though, honestly 87 isn't really hard and I probably should've chosen it to keep a contiguous block of unoccupied bytecounts on the low end :P – HyperNeutrino – 2017-10-27T14:30:30.220

    3

    242. FriCAS, 111 bytes, A000230

    a: (Integer) -> Integer
    a(n) ==
     i:=2
     repeat
      j:=nextPrime(i)
      if j-i = 2*n or n = 0 then
       return i
      i:=j
    

    Try it online here

    Next Sequence

    Pretty straightforward.

    KSmarts

    Posted 2017-07-21T15:00:01.030

    Reputation: 1 830

    2

    Ack, I spent too long testing my Pip solution!

    – DLosc – 2017-10-28T16:57:51.127

    @DLosc This seems to be the theme of this challenge... – NieDzejkob – 2017-10-30T06:24:04.823

    3

    243. Ly, 112 bytes, A000111

    1<<<<111<n2-0G*
    [
     >&s0>l>lr>1>&s>lp
     [
      sp<l+sp<l>>
     ]
     <p<1&s>l<
     [
      sp<l*sp<l*sp<l+>>>
     ]
     <p<p<<,
    ]
    p>u&p;
    

    Try it online!

    Next sequence

    This uses the recurrence a(n) = Sum_{i=0..n-2} binomial(n-2,i)*a(i)*a(n-1-i).

    Using the recurrence for one value needs all the binomials from one row in Pascal's tringle, and then the next value needs the next row, so we compute one row from the previous one by addition, avoiding factorials and divisions, so Ly will stay in the realm of integers and not switch to floats.

    Ly uses an infinite strip of stacks, of which we're using seven. For reference, let's call them, from left to right: count, vals, oldvals, oldvalsR, bins, oldbins, and oldbinsT. The stack that we are at in the beginning will be used as oldbins, just because this is the rightmost that needs initialisation. We can move between the stacks with < and >.

    We initialise oldbins with 1, the first row of Pascal's triangle. Then we initialise vals with the first three values, which are all 1. Next, we read the input into count and subtract 2, then 0G* will turn that into 0 if it was negative.

    Now count tells us how many more values we need. Next we'll have a loop with this loop invariant: vals contains some initial values of the series, we are at count which holds one nonnegative number that tells how many more values are needed, oldbins contains the row of Pascal's triangle that was used for the last value, and the other stacks are empty.

    (We didn't really use the first row of the triangle, but we would have needed it if we had computed a(2) from the recurrence. We don't start with only two values, because there is no 0th row from which we can compute the first without complicating the algorithm. We could also store the row we need next, but then we would needlessly compute one row more than needed.)

    The looping construct [...] loops while the stack is not empty and its top element isn't zero. The outer loop will be terminated when count is zero, all other loops will be terminated by empty stacks.

    To prepare for the work in the loop, we copy the vals stack to the backup cell using &s, then add a zero to this stack as initial value for the sum. Then we store the value of the backup cell to oldvals (with l) and also to oldvalsR, where we reverse it with r. Then we push the first value 1 of the new row of Pascal's triangle to bins, copy oldbins to oldbinsT and drop its first element there (with p).

    We can think of the computation of bins as equivalent to this Haskell computation:

    [1] ++ zipWith(+) oldbins oldbinsT ++ [1]   where oldbinsT = tail oldbins
    

    The inner loop then copies (s) the top element from oldbinsT to the backup cell and drops it from the stack (p), and puts it on top of the oldbins stack, where it is added to the former top element. This sum is then moved (again with sp<l) to the bins stack. The loop body is completed by going back to the oldbinsT stack. (Note that at the first iteration of the outer loop, this loop will terminate immediately.)

    After this loop, the remaining value from oldbins is dropped, and the final 1 value appended to bins. Then bins is copied to oldbins.

    The second inner loop is like this Haskell code:

    sum ( zipWith3 (\a b c->a*b*c) oldvals oldvalsR bins )
    

    Note that bins has one value less than the two other stacks, so we use this to control the loop. In it, we move the top value to oldvalsR and multiply, then move the result to oldvals and multiply again. This product is moved to vals and added to the accumulated sum on its top. (Remember that we already pushed a zero here.)

    When the loop is done, we drop the remaining values from oldvalsR and oldvals and decrement count (with ,).

    When the outer loop is done, we needlessly drop the zero from count and output (and drop) the top element from vals. Finally, we delete this whole stack with &p and explicitely end the program with ;. We don't need both, but if we didn't do either, implicit output would print all values from vals.

    Christian Sievers

    Posted 2017-07-21T15:00:01.030

    Reputation: 6 366

    Oh yes, I was late for 4 hours this time... Anyway my Enlist code: Try it online! (try on Python because Dennis hasn't pull latest version of Enlist, or at least I guess so)

    – user202729 – 2017-10-31T13:53:32.530

    1@user202729 503 Backend fetch failed. – Christian Sievers – 2017-10-31T14:01:44.780

    ↑↑ Explanation: That was O(n! * n) algorithm finding all permutation and count number of alternating permutation. – user202729 – 2017-10-31T14:04:20.830

    @user202729 Ah, I wondered what your approach was. What would your next sequence have been? – Christian Sievers – 2017-10-31T14:07:28.867

    Very small byte-count (of course Enlist is an efficient golfing language). Probably the smallest available, but if I don't like that sequence I may pad with spaces. – user202729 – 2017-10-31T14:16:41.880

    1@user202729 All those formulas and generating functions listed on the OEIS page, with sample programs in five different languages, and you decided to brute-force it. Good job. – KSmarts – 2017-10-31T14:32:45.570

    1@KSmarts Confusingly many formulas, not that easy to find one that is useful. (Otherwise someone would have answered earlier.) If you like brute-forcing, that may be the way to go for the next sequence. – Christian Sievers – 2017-10-31T14:42:56.873

    @KSmarts I just suppose it was code-golf, because Enlist = golfing language. Also Enlist hasn't got complete built-in set, so using formulas may be harder than brute-force it. – user202729 – 2017-10-31T14:47:29.497

    @KSmarts Also: I found that formula too, but because this.

    – user202729 – 2017-10-31T14:49:18.497

    1@ChristianSievers Well, the first one E.g.f.: (1+sin(x))/cos(x) = tan(x) + sec(x) is pretty easy to understand, imo, but tough to implement in most languages. – KSmarts – 2017-10-31T15:25:11.747

    @KSmarts Well, "tough to implement" is not what I would call "useful". And one needs to know what e.g.f. means. BTW, the differential equation for the e.g.f. (it says o.g.f. but that is wrong) leads to a nice solution if you have lazy lists, but I didn't want to do generating functions again, when another nice and efficient way was available. – Christian Sievers – 2017-10-31T15:46:35.057

    Somehow I didn't realize the comment (503 Backend fetch failed) is referring to my TIO link until now. I have no idea why though, and I don't keep the code. (I didn't intend to ping ChristianSievers by this comment) – user202729 – 2017-11-03T13:35:48.477

    Is there an algorithm or formula for he next sequence? Links? – Husnain Raza – 2017-11-03T20:14:56.213

    Oh come on folks, you have done more difficult sequences than the next one! – Christian Sievers – 2017-11-05T17:32:17.727

    @HusnainRaza An algorithm is described here. It's basically graph isomorphism for a certain subset of digraphs.

    – KSmarts – 2017-11-05T23:07:48.703

    @ChristianSievers I've done the next one already, but don't want to post it, see https://chat.stackexchange.com/transcript/message/40971284#40971284

    – user202729 – 2017-11-06T04:25:15.663

    @KSmarts ↑ too. Other interested people had already been pinged in the next chat messages. – user202729 – 2017-11-06T04:25:27.947

    But question dies tomorrow :( – Husnain Raza – 2017-11-06T04:29:16.463

    3

    245. Java 7, 1272 bytes, A001524

    import java.util.*;
    
    public class Main {
    	public static List<List<Long>> partitions(long val) {
    		List<List<Long>> list = new ArrayList<>();
    		if (val == 0) {
    			List<Long> sublist;
    			list.add(sublist = new ArrayList<>());
    		} else {
    			for (int i = 1; i <= val; i++) {
    				for (List<Long> ext : partitions(val - i)) {
    					List<Long> sublist;
    					list.add(sublist = new ArrayList<>());
    					sublist.add((long) i);
    					sublist.addAll(ext);
    				}
    			}
    		} return list;
    	}
    
    	public static List<List<Long>> filter(List<List<Long>> partitions) {
    		List<List<Long>> list = new ArrayList<>();
    		outerloop: for (List<Long> sublist : partitions) {
    			for (int i = 0; i < sublist.size() - 1; i++) {
    				if (sublist.get(i) <= sublist.get(i + 1)) continue outerloop;
    			} list.add(sublist);
    		} return list;
    	}
    
    	public static long variants(List<Long> stack) {
    		int variants = 1;
    		for (int i = 0; i < stack.size() - 1; i++) {
    			variants *= stack.get(i) - stack.get(i + 1);
    		} return variants;
    	}
    
    	public static long A001524(long val) {
    		long out = 0;
    		for (List<Long> stack : filter(partitions(val))) out += variants(stack);
    		return out;
    	}
    
    	public static void main(String[] args) {
    		for (long i = 0; i < 10; i++) {
    			System.out.println(i + ": " + A001524(i));
    		}
    	}
    }
    

    Try it online!

    This isn't too slow though it probably could be improved. This sequence was fairly simple but 1272 bytes because Java.

    Next Sequence

    HyperNeutrino

    Posted 2017-07-21T15:00:01.030

    Reputation: 26 575

    The only reason I didn't beat you to this is that my Python-based solution was too slow. It took more than a minute for A(3)... – KSmarts – 2017-11-06T15:03:32.930

    @KSmarts Can I see your solution? How was it that slow D: – HyperNeutrino – 2017-11-06T15:05:06.850

    Lots of recursion. – KSmarts – 2017-11-06T15:17:36.823

    @KSmarts ಠ_ಠ that much recursion is 0/10 but regardless, nice :P

    – HyperNeutrino – 2017-11-06T15:23:51.670

    @KSmarts You might want to try memoization – Christian Sievers – 2017-11-06T16:01:52.303

    3

    246. Coconut, 240 bytes, A001272

    import math
    
    def p(a): return not (a < 2 or any(a % x == 0 for x in range(2, int(a**0.5) + 1)))
    
    def A(n):
     m=n+1
     i=k=0
     while k<m:
      i= i + 1
      x=0
      for j in range(1,i+1):
       x = x+(-1)**(i-j)*math.factorial(j)
      if p(x): k=k+1
     return i
    

    Next Sequence

    Try it online!

    KSmarts

    Posted 2017-07-21T15:00:01.030

    Reputation: 1 830

    My Enlist code was late again. Partial code

    – user202729 – 2017-11-06T15:51:41.440

    Since Coconut can execute nearly any Python code, there are now six Pythons to choose from ... :p – Jonathan Frech – 2017-11-07T19:55:17.983

    @JonathanFrech According to their homepage (linked in the header), all valid Python is valid Coconut. Have fun! – KSmarts – 2017-11-07T20:00:22.680

    @KSmarts The only annoying thing from a golfing perspective is that this is not entirely true, as -- for example -- the piece of code linked to can be considered valid Python 2 code.

    – Jonathan Frech – 2017-11-07T20:04:28.317

    3

    247. Enlist, 87 bytes, A000240

    RṖ†eṢS=1§€S                                                                            
    

    Try it online!

    Next sequence.


    Explanation:

     Ṗ           All permutations of
    R            the ranges from 1 to n.
      †     §€   For each of them
       eṢ        Calculate the equality of that list with the sorted list (which is the range from 1 to n)
         S       Sum. Now the value is the number of fixed point of that permutation.
          =1     Return 1 if the number of fixed point is 1, and 0 otherwise.
             S   Sum of the values -> number of permutations such that number of fixed point is 1.
    

    user202729

    Posted 2017-07-21T15:00:01.030

    Reputation: 14 620

    What is the next sequence? Definitely not A000011. Code snippet need to be changed. – user202729 – 2017-11-06T16:02:25.703

    According to OP's snippet, it's A000087. (Not sure how accurate that is, though)

    – J. Sallé – 2017-11-06T16:04:42.693

    1"your bytecount must be unique." Please change this to match that requirement. – caird coinheringaahing – 2017-11-06T16:50:07.093

    @cairdcoinheringaahing Oh yes. Sorry. I thought the rule was "if the sequence is already used then the next sequence is the lowest unused one". – user202729 – 2017-11-07T00:25:07.550

    1:DD :DDDD Enlist got used for something cool :D +1 – HyperNeutrino – 2017-11-07T13:20:31.833

    @HyperNeutrino https://codegolf.stackexchange.com/questions/133754/one-oeis-after-another/147244?noredirect=1#comment359085_146719 (it does work, but the link is dead) Definitely not for the first time.

    – user202729 – 2017-11-07T13:21:40.600

    3

    248. Huginn, 904 bytes, A000087

    import Algorithms as alg;
    
    gcd( a_, b_ ) {
     u = integer( a_ );
     v = integer( b_ );
     while ( v > 0 ) {
        t = u;
        u = v;
        v = t % v;
      }
      return( u );
    }
    
    eulerPhi( n_ ) {
     n = integer( n_ );
     x = 0;
     for ( i : alg.range( 1, n + 1 ) ) {
      if ( gcd( i, n ) == 1 ) {
       x += 1;
      }
     }
     return ( x );
    }
    
    binomial( n_, k_ ) {
     n = integer( n_ );
     k = integer( k_ );
     x = 1;
     for ( i : alg.range( 1, k + 1 ) ) {
      x = x * (n - i + 1) / i;
     }
     return ( x );
    }
    
    A000087( n_ ) {
     n = integer( n_ ) + 1;
     z = 0.0 ;
     for ( k : alg.range( 1, n ) ) {
      if ( n % k == 0 ) {
       z += real( eulerPhi( n / k ) * binomial( 3 * k, k ) );
      }
     }
     z += real( ( n + 2 ) * binomial( 3 * n, n ) ) / real( ( 3 * n - 2 ) * ( 3 * n - 1 ) );
     z = z / real( 3 * n );
     if ( n % 2 == 1 ) {
      z += real( 2 * ( n + 1 ) * binomial( 3 * ( n + 1 ) / 2, ( n + 1 ) / 2 ) ) / real( 3 * ( 3 * n - 1 ) * ( 3 * n + 1 ) );
     }
     return( z );
    }
    

    Next Sequence

    Try it online!

    This uses the formula from the OEIS page, which is a little complicated, but not too hard once you break it down.

    KSmarts

    Posted 2017-07-21T15:00:01.030

    Reputation: 1 830

    What is a map? Is it a graph? Wikipedia doesn't explain too well: https://en.wikipedia.org/wiki/Planar_graph

    – user202729 – 2017-11-08T10:02:13.433

    3

    251. C (tcc), 269 bytes, A000711

    long p(int k,int n,int*a,int l){long s=1;if(n<1)return!l;a[l]=n;for(int i=1,c,j;i<=k;i++){for(j=0,c=1;j<=l;j++)if(a[j]==i)c++;s*=(i<5)?((c)*(c+1)/2):c;}for(int i=(l==0)?1:a[l-1];i<=n/2;i++)a[l]=i,s+=p(k,n-i,a,l+1);return s;}long a(int n){int a[1000];return p(n,n,a,0);}
    

    Try it online!

    Next sequence!

    Explanation

    // Takes a partition a of the number k and returns how many different
    // partitions it represents if the numbers can have many kinds, according
    // to the specification of the sequence. For example:
    // [1 1 1] =>
    //    [1  1  1 ]
    //    [1  1  1']
    //    [1  1' 1']
    //    [1' 1' 1']
    //    [1' 1' 1"]
    //    [1' 1" 1"]
    //    [1" 1" 1"]
    // Each different number in the partition can be processed separately,
    // and the "score" will be the product of the scores of each number.
    long score(int k, int length, int * a){
        long product = 1;
    
        for(int i = 1;i <= k;i++){ // A partition of k can contain numbers [1,k]
            int count = 0; // Count how many times the number i appears
            for(int j = 0;j <= length;j++){
                if(a[j] == i) c++;
            }
    
            if(i < 5){
                // i has 3 kinds. If you sort all the cases in ascending
                // "kind numbers", then the first Kind 2 (') can be in
                // (number of Kind >= 1, i. e. the variable c) + 1 positions:
                //    1  1  1
                //    1  1  1'
                //    1  1' 1'
                //    1' 1' 1'
                // Then, the first Kind 3 (") can be in (number of Kind >= 2) + 1
                // positions:
                //    1' 1' 1'
                //    1' 1' 1"
                //    1' 1" 1"
                //    1" 1" 1"
                // If you think about it, you'll get the sum of natural numbers
                // from 1 to (c + 1), for which there is a nice closed form
                // formula (look at sequence of answer number 1, don't forget
                // to rate the language choice ) (one problem Emoji solved
                // is ending a parenthesis with an emoticon).
                product *= ((c + 1) * (c + 2)) / 2;
            }else{
                product *= (c + 1);
            }
        }
    
        return product;
    }
    
    // A recursive function that enumerates all partitions of n, scores each
    // and returns the sum of all scores. The partitions are generated at
    // (a + level)
    // Pseudocode algorithm:
    // def partitions(n):
    //     yield [n]
    //     for i in range(1, n):
    //         for p in partitions(n - i):
    //             yield [n] + p
    // Notice how we don't really need to check the whole range of [1, n)
    // k is only relevant for scoring
    // the partitions are generated at (a + level)
    long partitions(int k, int n, int * a, int level){
        if(n < 1){
            if(l == 0){
                return 1; // l == 0 => this is the top level call, so include
                // the case of []
            }else{
                return 0; // doesn't happen, but I think this is the best
                // way to handle this edge case
            }
        }
    
        a[l] = n;
        long score_sum = score(k, l + 1, a);
    
        int start;
    
        if(l == 0){
            start = 1;
        }else{
            start = a[l - 1];
        }
    
        for(int i = start;i <= n/2;i++){
            a[l]=i;
            score_sum += partitions(k,n-i,a,l+1);
        }
    
        return score_sum;
    }
    
    long a(int n){
        // the longest partition of k is [1]*k, speaking Python,
        // so let's not bother with dynamic allocation
        int a[1000];
        return partitions(n, n, a, 0);
    }
    

    NieDzejkob

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 630

    My Jelly code: https://chat.stackexchange.com/transcript/message/41118715#41118715

    – user202729 – 2017-11-13T14:14:54.853

    Please don't golf your answer, make it readable instead. This isn't even code-golf. – user202729 – 2017-11-13T14:36:08.463

    1@user202729 but it's fun! OK, I'll add a readable version – NieDzejkob – 2017-11-13T14:46:23.453

    My Jelly code is even more efficient than yours, and only at number of bytecount ~ 8.2% of yours. – user202729 – 2017-11-13T14:52:07.213

    @user202729 But is it more readable? – Christian Sievers – 2017-11-13T15:05:57.707

    @ChristianSievers Certainly more readable to Jelly users who don't like scrolling the screen. Will add an explanation soon. – user202729 – 2017-11-13T15:13:04.847

    Why do you even have to pass the array a around? Why not just make it a global variable? Also n<1 can be written as !n if you know that n >= 0. – user202729 – 2017-11-13T15:58:08.900

    @user202729 I could do that, but I didn't. No idea why. Don't ask. I don't like globals. !n is equivalent to n != 0, which you can see used in my code. However, <s>this part is partly a failsafe, which is why I didn't want to golf it that way</s> I just didn't notice :P Edit: ugh, how does one do strikethrough in Markdown? – NieDzejkob – 2017-11-13T16:11:16.247

    No idea. I tried both ---abc--- (works in chat) and <s>abc</s> (works in main post). They doesn't work. abc ___def___ *ghi* ← tests – user202729 – 2017-11-13T16:20:08.493

    3

    252. Pari/GP, 251 bytes, A000269

    A000081(n) = if( n<3, if(n<1,0,1) , 1/(n-1)*sum(k=1,n-1,sumdiv(k,d,d*A000081(d))*A000081(n-k) ) );
    
    gfA81(n) = sum( i=0, n, A000081(i)*x^i, O(x^(n+1)) );
    
    gfA269(n) = {Bx = gfA81(n); Bx^3 * (3-2*Bx) / (1-Bx)^3}
    
    A000269(n) = polcoeff(gfA269(n+3), n+3)
    

    Next Sequence

    Try it online!

    This uses the generating function formula, by directly computing values of the sequence A000081.

    KSmarts

    Posted 2017-07-21T15:00:01.030

    Reputation: 1 830

    Does anyone have access to that paper? I don't see how we're supposed that in less than O(silly(n))... – NieDzejkob – 2017-11-16T08:48:40.917

    @NieDzejkob I have it now. I can implement the sequence in Haskell with the usual stuff for handling generating functions plus three one-line definitions. – Christian Sievers – 2017-11-16T23:12:19.747

    @NieDzejkob It doesn't have to be efficient. – KSmarts – 2017-11-17T14:13:57.250

    @KSmarts if it's fast enough for small n that you can convince yourself that it works... – NieDzejkob – 2017-11-17T18:04:43.160

    Rip challenge :( – Husnain Raza – 2017-11-20T03:53:34.447

    @HusnainRaza 7 hours left, not all hope is lost. – NieDzejkob – 2017-11-20T09:40:38.963

    3

    258. Forth (gforth), 329 bytes, A000144

    : ODDQ 2 MOD ;
    : EVENQ 1+ ODDQ ;
    : DIVOK /MOD SWAP IF DROP 0 ELSE ODDQ THEN ;
    : A2131 DUP 1+ 0 SWAP 1 ?DO OVER I DIVOK IF I + THEN LOOP NIP ;
    : A186690 DUP A2131 SWAP EVENQ IF 0 SWAP - THEN ;
    : ADVANCE DUP 1+ 0 SWAP 1 ?DO I 1+ PICK I A186690 * + LOOP 20 * OVER / SWAP 1+ ;
    : A144 1 SWAP 1 SWAP 0 ?DO ADVANCE LOOP 1 ?DO NIP LOOP ;
    

    Try it online!

    Next sequence!

    This time I managed to remove the surplus elements from the stack with 1 ?DO NIP LOOP.

    NieDzejkob

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 630

    Learn a new language just to use it twice... – user202729 – 2017-11-21T09:55:06.947

    @user202729 no, I learned it for a much larger project. It involves bootstrapping Linux from less than 1K binaries, and Forth is a good language thanks for its small interpreter. – NieDzejkob – 2017-11-21T10:36:53.277

    I'm worried about the accuracy of the solution of the next sequence... This Jelly solution only survive up to n=13.

    – user202729 – 2017-11-21T10:38:32.943

    and is non-esoteric. BF interpreter is also small. – user202729 – 2017-11-21T10:39:04.930

    But why don't you just use assembly? – user202729 – 2017-11-21T10:42:49.893

    @user202729 I am using assembly too, but to use it in place of forth, I would need to fit an assembler in 1K. – NieDzejkob – 2017-11-21T12:35:25.460

    @Husnain Raza This answer got deleted because of floating point inaccuracies, this is no longer the next sequence. – NieDzejkob – 2017-11-21T20:28:10.110

    @HusnainRaza Which sequence are you referring to? – user202729 – 2017-11-22T05:56:00.503

    Apparently my comment above is correct. You do need big floating point for that. The answer to the next sequence (A000329) is deleted because of that reason. chat room

    – user202729 – 2017-11-22T05:58:01.007

    3

    267. Erlang (escript), 338 bytes, A002572

    
    h(N,A,_) when A > N -> 0;
    h(N,A,_) when A == N -> 1;
    h(N,A,B) -> case erlang:get({N,A,B}) of
    	F when is_integer(F) -> F;
    	'undefined' -> 
    		F = lists:sum(lists:map(
    			fun(I) -> h(N-I, (A-I)*2, B+1) end,
    		lists:seq(0, A-1))),
    		erlang:put({N,A,B}, F),
    		F
    	end.
    
    main([])-> {ok, [N]} = io:fread("", "~d"),
    io:fwrite("~p", [h(N+1,1,0)]).
    

    Try it online!

    Next sequence!

    I first wrote this in Python, and then I had decided to find a language with bignums, because this sequence grows pretty quickly. I hope this will explain it pretty well:

    cache = {}
    # Calculate the number of partitions of a/(2^b) into n powers of (1/2), with
    # the exponent of at least b. You need at least a powers of (1/2) for the
    # trivial solution of a*(1/2)^b, and you cannot write any of the fractions
    # in that solution as a sum of smaller fractions if a = n.
    def B(n, a, b):
        if a > n:
            return 0
    
        if a == n:
            return 1
    
        if (n, a, b) not in cache:
    # We need more fractions - use 1/(2^b) from 0 to (a-1) times, and fill
    # the rest with the recursive call of this function
    
            s = 0
            for i in range(a):
                s += B(n - i, # we used i fractions
                       (a - i) * 2, # use a higher power of (1/2)
                       b + 1)
            cache[(n, a, b)] = s
    
        return cache[(n, a, b)]
    
    def A(n):
        return B(n, 1, 0)
    
    for n in range(1, 2000):
        print(n, A(n))

    Memoization in Erlang from this SO answer

    NieDzejkob

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 630

    1+1 from me. I really don't understand your ability to port stuff that easily to new languages. – Mr. Xcoder – 2017-11-30T18:57:13.140

    3

    268. Pyke, 99 bytes, A000338

    9 2/Q2+X*15 2/Q2+*-BQ1>*Q0q5*Q1q18*++                                                              
    

    Try it here!

    Next sequence. (quite tendious, yet doable I think)

    Mr. Xcoder

    Posted 2017-07-21T15:00:01.030

    Reputation: 39 774

    1The next sequence is definitely doable. It looks more tedious than hard to me. – KSmarts – 2017-11-30T19:38:39.417

    3

    269. Pip, 118 bytes, A000099

    n:0
    m:0
    ++a
    W a {
      ++n
      Y -n\,n
      AA:{$+a*a<=n} MS yCPy
      VV:PI*n
      PP:AA-VV
      I ABPP>m {
        m:ABPP
        --a
      }
    }
    n
    

    Try it online! (times out for indices greater than 7)

    Next sequence

    Commented

    Implements the definition of the sequence:

    n:0            Index of helper sequences
    m:0            Max value of |P(n)| so far
    ++a            Index of main sequence (++ because the definition is 1-indexed)
    W a {          Count down until a hits 0:
      ++n           Increment index of helper sequence
      Y -n\,n       Yank inclusive range [-n, n]
      AA:           Sequence A(n) is:
        {$+a*a<=n}   Function: Square items of list, sum, and check <= n
        MS           Map-sum
        yCPy         Cartesian product of y with itself
      VV:PI*n       Sequence V(n) is pi times n
      PP:AA-VV      Sequence P(n) is A(n)-V(n)
      I ABPP>m {    If abs(P(n)) > current max value:
        m:ABPP       Max is abs(P(n))
        --a          Decrement index of main sequence
      }
    }
    n              Output index of helper sequence at the a'th maximum
    

    DLosc

    Posted 2017-07-21T15:00:01.030

    Reputation: 21 213

    1Did you check that the Pi constant has enough accuracy to compute 1000 terms? – NieDzejkob – 2017-11-30T21:32:22.453

    @NieDzejkob I believe it will. It's got about 16 significant digits, and if the series is ~= 0.0139 * n^4 (which is a pretty good fit for the first 200 terms), it should only require 11 significant digits to compute n = 1000. But I would have to compute that many terms to find out, and that would take days. Maybe I could write a C program to check... – DLosc – 2017-11-30T21:48:02.650

    3

    272. SNOBOL4 (CSNOBOL4), 129 bytes, A010008

    	INPUT('READLINE', 5)
    	IN = READLINE
    	OUTPUT('PRINT', 6)
    	EQ(IN,0)			:S(OK)	
    	OUTPUT = 18 * IN * IN + 2	:(END)
    OK
    	OUTPUT = 1
    END
    

    Try it online!

    Next sequence

    I think I could probably write another answer in SNOBOL; it took me a good ten minutes to figure out how to do I/O because I'm dumb, and I'm lucky the sequence was so stupidly easy.

    Explanation:

    SNOBOL is pretty old, so it has some weird quirks for someone who's been using more "modern" languages. First of all, you have to indent lines, because un-indented lines are labels. Control flow is purely through GOTOs, labels, and SUCCESS/FAILURE of a line. And I'm still not sure about how to write a comment.

    INPUT('READLINE', 5) sets a variable READLINE that takes input from file 5, which is by default the keyboard/console input.

    IN = READLINE reads a single line from the file as a string.

    OUTPUT('PRINT', 6) sets a variable PRINT that prints to file 6, which is by default the console.

    EQ(IN,0) tests for equality between the input and 0. The GOTO:S(OK) is the instruction "on Success, goto OK", so it jumps to OK, setting OUTPUT to 1, printing, and then hitting END.

    Otherwise, it sets the output to 18*n^2+2 and jumps to the END, terminating the program.

    Giuseppe

    Posted 2017-07-21T15:00:01.030

    Reputation: 21 077

    2I've heard that that kind of control flow is considered harmful. – KSmarts – 2017-12-07T20:25:08.237

    3

    274. ArnoldC, 1021 bytes, A000123

    IT'S SHOWTIME
    HEY CHRISTMAS TREE INPUT
    YOU SET US UP @I LIED
    HEY CHRISTMAS TREE OUTPUT
    YOU SET US UP @I LIED
    GET YOUR ASS TO MARS INPUT
    DO IT NOW
    I WANT TO ASK YOU A BUNCH OF QUESTIONS AND I WANT TO HAVE THEM ANSWERED IMMEDIATELY
    GET YOUR ASS TO MARS OUTPUT
    DO IT NOW A000123 INPUT
    TALK TO THE HAND OUTPUT
    YOU HAVE BEEN TERMINATED
    
    LISTEN TO ME VERY CAREFULLY A000123
    I NEED YOUR CLOTHES YOUR BOOTS AND YOUR MOTORCYCLE INDEX
    GIVE THESE PEOPLE AIR
    HEY CHRISTMAS TREE NUMBER1
    YOU SET US UP @NO PROBLEMO
    HEY CHRISTMAS TREE NUMBER2
    YOU SET US UP @NO PROBLEMO
    BECAUSE I'M GOING TO SAY PLEASE INDEX
    GET TO THE CHOPPER NUMBER1
    HERE IS MY INVITATION INDEX
    GET DOWN 1
    ENOUGH TALK
    GET TO THE CHOPPER NUMBER2
    HERE IS MY INVITATION INDEX
    HE HAD TO SPLIT 2
    ENOUGH TALK
    GET YOUR ASS TO MARS NUMBER1
    DO IT NOW A000123 NUMBER1
    GET YOUR ASS TO MARS NUMBER2
    DO IT NOW A000123 NUMBER2
    GET TO THE CHOPPER NUMBER1
    HERE IS MY INVITATION NUMBER1
    GET UP NUMBER2
    ENOUGH TALK
    YOU HAVE NO RESPECT FOR LOGIC
    I'LL BE BACK NUMBER1
    HASTA LA VISTA, BABY
    

    Try it online!

    Next Sequence

    Uses the recurrence relation a(n) = a(n-1) + a(floor(n/2))

    KSmarts

    Posted 2017-07-21T15:00:01.030

    Reputation: 1 830

    3

    278. Java 6, 5692 bytes, A000104

    import java.util.List;
    import java.util.ArrayList;
    import java.util.Set;
    import java.util.HashSet;
    import java.util.Iterator;
    import java.util.Scanner;
    
    final class Main {
    	static final Set<Pair> offsets;
    
    	static {
    		offsets = new HashSet<Pair>();
    		offsets.add(new Pair(0, +1));
    		offsets.add(new Pair(0, -1));
    		offsets.add(new Pair(+1, 0));
    		offsets.add(new Pair(-1, 0));
    	}
    
    	static final class Pair {
    		final int x, y;
    
    		Pair(int x, int y) {
    			this.x = x;
    			this.y = y;
    		}
    
    		public String toString() {
    			return "(" + this.x + ", " + this.y + ")";
    		}
    
    		public boolean equals(Object other) {
    			if (other == null) {
    				return false;
    			} else if (other instanceof Pair) {
    				Pair pair = (Pair) other;
    				return this.x == pair.x && this.y == pair.y;
    			} else {
    				return false;
    			}
    		}
    
    		public int hashCode() {
    			return this.x ^ this.y; // Expect many collisions with this hashcode; it's mostly just to make sure the hashset actually checks for equality) //
    		}
    
    		public Pair add(Pair pair) {
    			return new Pair(this.x + pair.x, this.y + pair.y);
    		}
    	}
    
    	private Main() {}
    
    	public static Set<Pair> rotate(Set<Pair> polyomino) {
    		Set<Pair> result = new HashSet<Pair>();
    		for (Pair pair : polyomino)
    			result.add(new Pair(-pair.y, pair.x));
    		return result;
    	}
    
    	public static Set<Pair> conjugate(Set<Pair> polyomino) {
    		Set<Pair> result = new HashSet<Pair>();
    		for (Pair pair : polyomino)
    			result.add(new Pair(pair.x, -pair.y));
    		return result;
    	}
    
    	public static List<Set<Pair>> variants(Set<Pair> polyomino) {
    		List<Set<Pair>> results = new ArrayList<Set<Pair>>();
    		for (int x = 0; x < 4; x++) {
    			polyomino = rotate(polyomino);
    			results.add(polyomino);
    			results.add(conjugate(polyomino));
    		}
    		return results;
    	}
    
    	public static Set<Integer> x(Set<Pair> polyomino) {
    		Set<Integer> results = new HashSet<Integer>();
    		for (Pair pair : polyomino)
    			results.add(pair.x);
    		return results;
    	}
    
    	public static Set<Integer> y(Set<Pair> polyomino) {
    		Set<Integer> results = new HashSet<Integer>();
    		for (Pair pair : polyomino)
    			results.add(pair.y);
    		return results;
    	}
    
    	public static int max(Set<Integer> set) {
    		if (set.size() == 0) throw new IllegalArgumentException("max arg is an empty sequence");
    		Iterator<Integer> iterator = set.iterator();
    		int max = iterator.next();
    		while (iterator.hasNext()) {
    			int value = iterator.next();
    			max = max > value ? max : value;
    		}
    		return max;
    	}
    
    	public static int min(Set<Integer> set) {
    		if (set.size() == 0) throw new IllegalArgumentException("min arg is an empty sequence");
    		Iterator<Integer> iterator = set.iterator();
    		int min = iterator.next();
    		while (iterator.hasNext()) {
    			int value = iterator.next();
    			min = min < value ? min : value;
    		}
    		return min;
    	}
    
    	public static Pair corner(Set<Pair> polyomino) {
    		return new Pair(min(x(polyomino)), min(y(polyomino)));
    	}
    
    	public static Set<Pair> normalize(Set<Pair> polyomino) {
    		Pair cn = corner(polyomino);
    		Set<Pair> results = new HashSet<Pair>();
    		for (Pair pair : polyomino)
    			results.add(new Pair(pair.x - cn.x, pair.y - cn.y));
    		return results;
    	}
    
    	public static boolean translations(Set<Pair> p1, Set<Pair> p2) {
    		return normalize(p1).equals(normalize(p2));
    	}
    
    	public static boolean isomorphic(Set<Pair> p1, Set<Pair> p2) {
    		for (Set<Pair> p : variants(p1))
    			if (translations(p, p2))
    				return true;
    		return false;
    	}
    
    	public static boolean filled(Set<Pair> polyomino) {
    		Set<Integer> x = x(polyomino);
    		Set<Integer> y = y(polyomino);
    		for (int i = min(x) + 1; i < max(x); i++) {
    			for (int j = min(y) + 1; j < max(y); j++) {
    				if (!polyomino.contains(new Pair(i, j))
    				&&   polyomino.contains(new Pair(i, j + 1))
    				&&   polyomino.contains(new Pair(i, j - 1))
    				&&   polyomino.contains(new Pair(i + 1, j))
    				&&   polyomino.contains(new Pair(i - 1, j)))
    					return false;
    			}
    		}
    		return true;
    	}
    
    	public static List<Set<Pair>> polyominoes(int cells) {
    		List<Set<Pair>> results = new ArrayList<Set<Pair>>();
    		if (cells == 0) {
    			results.add(new HashSet<Pair>());
    			return results;
    		} else if (cells == 1) {
    			Set<Pair> set = new HashSet<Pair>();
    			set.add(new Pair(0, 0));
    			results.add(set);
    			return results;
    		} else if (cells == 2) {
    			Set<Pair> set = new HashSet<Pair>();
    			set.add(new Pair(0, 0));
    			set.add(new Pair(0, 1));
    			results.add(set);
    			return results;
    		} else {
    			for (Set<Pair> polyomino : polyominoes(cells - 1)) {
    				for (Pair cell : polyomino) {
    					for (Pair offset : offsets) {
    						Set<Pair> variant = new HashSet<Pair>(polyomino);
    						variant.add(cell.add(offset));
    						if (variant.size() == cells) {
    							results.add(variant);
    						}
    					}
    				}
    			}
    		}
    		List<Set<Pair>> output = new ArrayList<Set<Pair>>();
    		outer: for (Set<Pair> r : results) {
    			for (Set<Pair> p : output) {
    				if (isomorphic(r, p)) {
    					continue outer;
    				}
    			}
    			if (filled(r)) output.add(r);
    		}
    		return output;
    	}
    
    	public static void main(String[] args) {
    		boolean visualizer = true; // Change to `false` to not show visualizations
    		int cells;
    		List<Set<Pair>> polyominoes = polyominoes(cells = new Scanner(System.in).nextInt());
    		System.out.println(polyominoes.size());
    		if (cells != 0 && visualizer) {
    			System.out.println();
    			for (Set<Pair> polyomino : polyominoes) {
    				Set<Integer> x = x(polyomino);
    				Set<Integer> y = y(polyomino);
    				int minx = min(x), maxx = max(x);
    				int miny = min(y), maxy = max(y);
    				for (int i = minx; i <= maxx; i++) {
    					for (int j = miny; j <= maxy; j++) {
    						System.out.print(polyomino.contains(new Pair(i, j)) ? '#' : '.');
    					} System.out.println();
    				} System.out.println();
    			}
    		}
    	}
    }
    

    Try it online!

    The TIO link links to the Java 8 interpreter but this answer works on Java 6 (tested locally thanks to user202729).

    Next Sequence - this one has enough terms to be hardcoded but please don't.

    Originally programmed in Python

    HyperNeutrino

    Posted 2017-07-21T15:00:01.030

    Reputation: 26 575

    Not enough. You need to support all n not "larger than 1000" - it means that all n such that 0 ≤ n ≤ 1000 need to be supported, that's 1001 terms. You are off by 1. – user202729 – 2017-12-13T14:45:49.697

    @user202729 lol oh. well, it's close :P In that case then, hardcoding it would require getting 1001 in which case one might as well solve it the correct way :p – HyperNeutrino – 2017-12-13T14:48:01.037

    2

    rules for the next sequence can be found here on page 13 since the OEIS page links to a JSTOR page and I didn't feel like registering there.

    – Giuseppe – 2017-12-13T14:48:06.337

    HyperNeutrino: Do you want to turn off the visualizer? – user202729 – 2017-12-13T14:49:35.160

    @user202729 No, I intentionally left it on. I don't think it makes the output invalid since it obviously gives the correct answer, but if you want, I can turn it off; I can easily keep the bytecount the same. – HyperNeutrino – 2017-12-13T14:52:56.740

    3

    284. Hexagony, 211 bytes, A000384

         ? } 2 \ . .
        . . . " . . .
       . @ ! * = < . .
      . . . > ( { / . .
     . . . . . . . . . .
    . . . . . . . . . . .
     . . . . . . . . . .
      . . . . . . . . .
       . . . . . . . .
        . . . . . . .
         . . . . . .
    

    Try it online!

    Next sequence!

    What better language is there to compute hexagonal numbers?

    Explanation

    I decided to make this code use each character (except ., space and newline) only once, because I had too much time on my hands. Let's label the edge the MP starts on A, the one to the left of it L and the one to the right - R. The following linear code gets executed:

    ?}2"*({=*!@
    ?           A = input()
     }2         R = 2
       "*       L = A * R = 2 * n
         (      L = L - 1 = 2 * n - 1
          {=*   R = A * L = n(2n-1) = a(n)
             !  Print the result
              @ End execution
    

    NieDzejkob

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 630

    3

    295. Unefunge-98 (PyFunge), 133 bytes, A000218

    #z3&#rz#;::/3*j$.@1-\:a%:*\a/:a%:*\a/:*++\#;r
    print(*map(lambda x:'pHra ywe!NY'[int(x, 16)], '%x'%(3*7*8*1821847*279590039)), sep='')
    

    Next sequence!

    Try it online!

    #z3&#rz#;::/3*j$.@1-\:a%:*\a/:a%:*\a/:*++\#;r
    #z                                            Kind of serves no purpose...
      3                                           Starting number of the sequence
       &                                          Input the number of iterations
        #rz#;                                 #;r Set up a way to jump to the
                                                  beginning
             ::/                                  Make a copy of the loop counter and
                                                  divide it by itself. Since 0/0 is
                                                  defined as 0 in Funge, this leaves
                                                  1 on the stack when the loop
                                                  counter is not zero, but 0 when it
                                                  is
                3*                                Multiply the result by 3 to skip
                                                  $.@
                  $.@                             When the loop ends, print the
                                                  result
                     1-                           Decrement the loop counter
                       \:a%:*\a/:a%:*\a/:*++\     Calculate the next element of the
                                                  sequence.
    

    NieDzejkob

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 630

    1+1 for a Python polyglot! (For anyone reading this, try running it in Python 3) – caird coinheringaahing – 2017-12-31T23:02:39.243

    Befure running it, try to look and guess what it does. Should be easy to guess even if you don't know Python. – user202729 – 2018-01-01T04:06:42.297

    3

    306. Python 3, 2113 bytes, A000145

    def intsqrt(n):
     if n == 0: return 0
     counter, temp = 1, 1
     while counter < n:
      counter <<= 2
      temp <<= 1
     oldtemp1, oldtemp2 = 0, 0
     while oldtemp2 != temp and temp > 0:
      oldtemp2, oldtemp1, temp = oldtemp1, temp, (temp + n // temp) >> 1
     return oldtemp1
    
    def factorial(n):
     if n == 0:
      return 1
     else:
      return n * factorial(n - 1)
    
    def GenerateSquareSequence(n):
     s = 0
     for a in range(intsqrt(n), -1, -1):
      for b in range(min(a, intsqrt(n - a*a)), -1, -1):
       for c in range(min(a, b, intsqrt(n - a*a - b*b)), -1, -1):
        for d in range(min(a, b, c, intsqrt(n - a*a - b*b - c*c)), -1, -1):
         for e in range(min(a, b, c, d, intsqrt(n - a*a - b*b - c*c - d*d)), -1, -1):
          for f in range(min(a, b, c, d, e, intsqrt(n - a*a - b*b - c*c - d*d - e*e)), -1, -1):
           for g in range(min(a, b, c, d, e, f, intsqrt(n - a*a - b*b - c*c - d*d - e*e - f*f)), -1, -1):
            for h in range(min(a, b, c, d, e, f, g, intsqrt(n - a*a - b*b - c*c - d*d - e*e - f*f - g*g)), -1, -1):
             for i in range(min(a, b, c, d, e, f, g, h, intsqrt(n - a*a - b*b - c*c - d*d - e*e - f*f - g*g - h*h)), -1, -1):
              for j in range(min(a, b, c, d, e, f, g, h, i, intsqrt(n - a*a - b*b - c*c - d*d - e*e - f*f - g*g - h*h - i*i)), -1, -1):
               for k in range(min(a, b, c, d, e, f, g, h, i, j, intsqrt(n - a*a - b*b - c*c - d*d - e*e - f*f - g*g - h*h - i*i - j*j)), -1, -1):
                for l in range(min(a, b, c, d, e, f, g, h, i, j, k, intsqrt(n - a*a - b*b - c*c - d*d - e*e - f*f - g*g - h*h - i*i - j*j - k*k)), -1, -1):
                 if a*a + b*b + c*c + d*d + e*e + f*f + g*g + h*h + i*i + j*j + k*k + l*l == n:
                  t = (a, b, c, d, e, f, g, h, i, j, k, l)
                  u = []
                  for m in range(0, 4096):
                   v = [t[o] * (-1)**(m >> o) for o in range(0, 12)] 
                   u.append(repr(sorted(v)))
                  w = set(u)
                  x = [eval(y) for y in w]
                  for z in x:
                   p = [z.count(o) for o in set(z)]
                   q = 479001600
                   for r in p:
                    q = q // factorial(r)
                   s += q
     return s
    

    Try it online!

    Next sequence: A002113: palindromic number

    Sorry for the counting by exhaustion algorithm (and the 14-layer for loop), but the sequence also counts representations with negative numbers into the total.

    Shieru Asakoto

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 445

    ... and for using Python. – user202729 – 2018-01-08T05:20:21.697

    (of course, anyone is free to use any language, just saying) – user202729 – 2018-01-08T05:27:42.727

    ... and for CamelCase function name. – NieDzejkob – 2018-01-08T13:53:30.077

    3

    307. Scratch 2, 6060 bytes, A002113

    enter image description here

    Try it online!

    Next Sequence

    Relevant part:

    "scripts": [[639, 148.5, [["letter:of:", 1, ["readVariable", "is_palindrome"]]]],
        [683, 370, [["readVariable", "counter"]]],
        [697, 365, [["readVariable", "n"]]],
        [59,
            92,
            [["whenGreenFlag"],
                ["deleteLine:ofList:", "all", "palindromes"],
                ["doAsk", "n: "],
                ["setVar:to:", "n", ["answer"]],
                ["setVar:to:", "counter", 0],
                ["doUntil",
                    ["=", ["lineCountOfList:", "palindromes"], ["readVariable", "n"]],
                    [["setVar:to:", "is_palindrome", "1"],
                        ["setVar:to:", "i", 0],
                        ["doRepeat",
                            ["stringLength:", ["readVariable", "counter"]],
                            [["doIf",
                                    ["not",
                                        ["=",
                                            ["letter:of:", ["+", ["readVariable", "i"], 1], ["readVariable", "counter"]],
                                            ["letter:of:",
                                                ["-", ["stringLength:", ["readVariable", "counter"]], ["readVariable", "i"]],
                                                ["readVariable", "counter"]]]],
                                    [["setVar:to:", "is_palindrome", 0]]],
                                ["changeVar:by:", "i", 1]]],
                        ["doIf",
                            ["=", ["readVariable", "is_palindrome"], "1"],
                            [["append:toList:", ["readVariable", "counter"], "palindromes"]]],
                        ["changeVar:by:", "counter", 1]]]]]],
    

    Full code: https://pastebin.com/jEc5W0SL

    PattuX

    Posted 2017-07-21T15:00:01.030

    Reputation: 361

    ... why is this one 1-indexing? – user202729 – 2018-01-08T08:50:49.063

    It seems too slow... – user202729 – 2018-01-08T08:51:45.927

    Could you make sure the offset is right? For instance, input 0 should give you an output of 0. I can't check this since something's wrong with flash in my browser. (since user202729 seems to be saying something) – NieDzejkob – 2018-01-08T15:13:33.897

    I've managed to get Flash to work, and this is unfortunately slightly invalid due to the rules about indexing sequences. For example, for all numbers less than 10 the program should output the index. Changing n to n-1 should fix this – NieDzejkob – 2018-01-09T16:00:02.203

    3

    311. ALGOL 68 (Genie), 334 bytes, A000148

    BEGIN
      LONG LONG INT n   := read int + 2;
      LONG LONG INT r   := 0;
      LONG LONG REAL ma := ( n / 2.0 ) ** 1.5;
      LONG LONG REAL x  := 2.0 / 3;
      INT a             := 1;
      WHILE a <= ma DO
        INT b := a;
        WHILE a ** x + b ** x <= n DO
          r := r + 1;
          b := b + 1
        OD;
        a := a + 1
      OD;
      print ( whole ( r , 0 ) )
    END
    

    Next Sequence

    Try it online!

    KSmarts

    Posted 2017-07-21T15:00:01.030

    Reputation: 1 830

    C (gcc) is allowed right now (2018-01-09), right? – SIGSTACKFAULT – 2018-01-09T18:46:48.240

    @Blacksilver looks like it, it's only been used twice so far. – Giuseppe – 2018-01-09T18:55:10.650

    3

    312. Python 2 (PyPy), 1811 bytes, A000334

    partition_result_set = []
    location_result_set = []
    big_max = 1
    
    def p_value(coord, value):
     global big_max
     i = value
     for d in coord:
      i = i * big_max + d
     return i
    
    def partition(number, max, row = []):
     global partition_result_set
     if number == 0:
      partition_result_set[len(row) - 1] += [row]
      return
     
     for i in range(max, 0, -1):
      if number >= i:
       partition(number - i, i, row + [i])
    
    def init_partitions(number):
     global partition_result_set
     for i in range(number):
      partition_result_set += [[]]
    
     partition(number, number)
    
    def enumerate_locations(number_of_blocks, dimension, have_locations = [], possible_locations = []):
     global g, result_set, y, big_max, partition_result_set, location_result_set
     
     if possible_locations == []: 
      possible_locations = [[0] * dimension]
      y = [0] * number_of_blocks
      temp = number_of_blocks
      while temp > 0:
       big_max *= 10
       temp //= 10
     
     for location in possible_locations:
      new_have_locations = have_locations + [location]
      new_possible_locations = [l for l in possible_locations if l != location]
      for i in range(dimension):
       m = [location[d] + (1 if i == d else 0) for d in range(dimension)]
       is_ok = True
       for j in range(dimension):
        n = [m[d] - (1 if j == d else 0) for d in range(dimension)]
        if [d for d in n if d < 0] == [] and n not in new_have_locations: is_ok = False
       if is_ok: new_possible_locations += [m]
    
      len1 = len(new_have_locations)
      for x in partition_result_set[len1 - 1]:
       location_result_set += [repr(sorted([p_value(new_have_locations[k], x[k]) for k in range(len1)]))]
      if number_of_blocks > 1:
       enumerate_locations(number_of_blocks - 1, dimension, new_have_locations, new_possible_locations)
    
    def A000334(n):
     init_partitions(n + 1)
     enumerate_locations(n + 1, 4)
     print len(set(location_result_set))
    

    Try it online!

    Next sequence: A001811, Laguerre Polynomial. At least there is a closed-form formula

    Sorry for Python again, but when the question comes to enumeration I think Python is the easiest way to deal the question with.

    Shieru Asakoto

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 445

    3

    313. PowerShell, 146 bytes, A001811

    function A001811($n){
        [System.Numerics.BigInteger]$a=1;
        for ($i=1; $i -le $n; $i++) {
            $a=$a*($i+4)*($i+4)/$i
        }
        return $a
    }
    

    Online test suite

    Next sequence: A000146

    Peter Taylor

    Posted 2017-07-21T15:00:01.030

    Reputation: 41 901

    3

    322. Mathematica (10.1), 150 bytes, A000249

    Symbol[StringJoin[FromCharacterCode[72], FromCharacterCode[101], FromCharacterCode[97], FromCharacterCode[100]]][#(****)&][Round[BesselK[Slot[1], 5]]]
    

    Next sequence

    A bit over-the-top due to the character requirement. Effectively the same as Round[#~BesselK~5]&.

    LegionMammal978

    Posted 2017-07-21T15:00:01.030

    Reputation: 15 731

    I was confused by (****) for a bit, until I remembered that Mathematica comment is (* ... *)... – user202729 – 2018-01-26T14:24:25.053

    3

    330. Shakespeare Programming Language, 1854 bytes, A000155

    Ye A000155 program.
    Ajax, a of n minus four.
    Brutus, a of n minus three.
    Cicero, a of n minus two.
    Dogberry, a of n minus one.
    Isabella, input.
    Miranda, counter.
    Timon, a of n.
    
    Act I: TBD.
    Scene I: Taking input.
    
    [Enter Isabella and Timon]
    
    Timon:
           Listen to your heart! Are you worse than the sum of a big old cat and
           a pig?
    
    Isabella:
           If so, you are me.
    
    Timon:
           If so, let us proceed to Act II. Are you as bad as the sum of a furry
           black cat and a pig?
    
    Isabella:
           If so, you are the sum of a beautiful trustworthy handsome pony and a
           coward.
    
    Timon:
           If so, let us proceed to Act II.
    
    [Exeunt Isabella and Timon]
    [Enter Brutus and Cicero]
    
    Brutus:
           You are a big chihuahua.
    
    Cicero:
           You are a horse.
    
    [Exeunt Brutus and Cicero]
    [Enter Dogberry and Miranda]
    
    Miranda:
           You are the sum of a amazing brave beautiful angel and a hog!
    
    Dogberry:
           You are a pretty cute pony.
    
    [Exit Dogberry]
    [Enter Timon]
    
    Scene II: The loop.
    
    Miranda:
           You are the sum of Ajax and the product of a sunny sky and the sum of
           the product of Brutus and the difference between me and the sum of an
           animal and a delicious cow and the product of Dogberry and the sum of
           me and a toad. Am I as big as Isabella?
    
    Timon:
           If so, let us proceed to Scene III.
    
    [Exit Timon]
    [Enter Ajax]
    
    Ajax:
           You are the sum of you and a lantern.
    
    Miranda:
           You are Brutus.
    
    [Exeunt Ajax and Miranda]
    [Enter Brutus and Cicero]
    
    Cicero:
           You are me.
    
    Brutus:
           You are Dogberry.
    
    [Exeunt Brutus and Cicero]
    [Enter Dogberry and Timon]
    
    Timon:
           You are me.
    
    [Exit Dogberry]
    [Enter Miranda]
    
    Miranda:
           Let us return to Scene II.
    
    Scene III: TBD.
    
    [Exit Miranda]
    [Enter Isabella]
    
    Act II: Finishing up.
    Scene I: Output.
    
    Isabella: Open thy heart!
    [Exeunt]
    

    Try it online!

    Next sequence!

    NieDzejkob

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 630

    Just when I was almost finished actually implementing the Bessel functions... – KSmarts – 2018-01-30T15:40:02.433

    I just realised that I forgot to fill in the act and scene titles... – NieDzejkob – 2018-02-05T14:23:37.943

    3

    335. Python 2 (Cython), 620 bytes, A000157

    from itertools import*
    from math import*
    from functools import*
    n=int(input())+1#offset 1
    a=0#answer
    for p in permutations(range(n)):
     for i in range(2**n):#inversion
      v=[0]*(2**n)#visited
      c=0#number of cycles
      e=1#all is even
      for x in range(2**n):
       if v[x]:continue
       w=1#1 if this cycle is even
       while 1>v[x]:
        v[x]=1;w^=1
        x=reduce(lambda x,y:x+x+y,[1&(x>>s)for s in p])^i
       e&=w;c+=1
      a+=2**c*(1+e)
    print(a//(2**n*factorial(n)*4))
    
    #Come on... it's not that hard.
    #Time complexity: 4**n*factorial(n)
    #Memory complexity: 2**n
    #(which is actually order of magnitude
    #faster than the naive algorithm)
    

    Try it online!

    Next sequence


    Originally intended to work in Python3, but Python 3 (Cython) raises an error "deallocating None".

    Sorry for using Python, but programming on mobile is not easy. Posted 2 days ago in chat while waiting for someone else to post, probably with another language.

    The next sequence has some chemistry-related things, but the recurrence relation is easy to implement. Ideally I hope someone will explain what the sequence is about. (I don't even explain most of my own answers...)

    (Side note: Syntax highlighting fails for some comments)

    user202729

    Posted 2017-07-21T15:00:01.030

    Reputation: 14 620

    Well done! You can compute c (and e) without explicitely looking at all possible inputs using linear algebra similar to what I did in answer no. 178 – Christian Sievers – 2018-02-17T09:03:18.380

    2Talking of "what the sequence is about", what's A000157 really? It's obviously not what the title says, but equivalence classes of some kind. – Peter Taylor – 2018-02-17T09:17:56.920

    I actually didn't read the paper, and I think the description of the other sequence is easier to understand, and my first try got it correctly. So I just calculate and halve the other sequence. – user202729 – 2018-02-17T09:25:09.540

    1@PeterTaylor After having read 3 papers in the A370 sequence I still can't find any reference to this sequence. No idea. – user202729 – 2018-02-17T09:44:26.520

    3

    346. C++14 (gcc), 3780 bytes, A000162

    // oeis
    
    #ifndef _GLIBCXX_DEBUG
    #define NDEBUG
    #endif
    #include <cassert>
    
    #include<iostream>
    #include<vector>
    #include<algorithm>
    
    using v1=std::vector<char>;
    using v2=std::vector<v1>;
    using v3=std::vector<v2>;
    
    template<class Ar>Ar zip(Ar const& a){
    	Ar result(a[0].size());
    	for(size_t y=a[0].size();y-->0;){
    		result[y].resize(a.size());
    		for(size_t x=a.size();x-->0;)
    			result[y][x]=a[x][y];
    	} return result;
    }
    
    template<class Ar>Ar rot1(Ar a){ // rotate cw, assume
    	// row-major, row counts down, columns count right
    	std::reverse(a.begin(),a.end());
    	return zip(a);
    }
    template<class Ar>Ar rot2(Ar a){ // reverse of rot1
    	a=zip(a);std::reverse(a.begin(),a.end());
    	return a;
    }
    
    template<class Fn>auto each(Fn f){//f must have type (T -> T)
    	return [f](auto&& ar){
    		for(auto& elem:ar)elem=f(std::move(elem));
    		return ar;
    	};
    }
    auto zipeach=each(zip<v2>);
    
    template<class Fn>auto twice(Fn f){//f must have type (T -> T)
    	return [f](auto&& ar){
    		return f(f(std::forward<decltype(ar)>(ar)));
    	};
    }
    
    template<class Ar>std::vector<Ar>allrot2(Ar a,std::vector<Ar>& result){
    	// calculate all (4) rot of the 2D array (a) and append to (result).
    	result.push_back(std::move(a));
    	for(int i=3;i-->0;)result.push_back(rot1(result.back()));
    	return result;
    }
    auto rot1each=each(rot1<v2>);
    
    std::vector<v3>allrot(v3 a){
    	std::vector<v3>result;
    	for(int i=0;i<4;++i){
    		/*
    		auto r2a=allrot2(a);
    		result.insert(result.end(),
    			std::make_move_iterator(r2a.begin()),
    			std::make_move_iterator(r2a.end()));
    		*/
    		allrot2(a,result);
    		a=rot1each(a);
    	}
    	a=zipeach(rot1(zipeach(a)));
    	allrot2(a,result);
    	a=each(twice(rot1<v2>))(a);
    	allrot2(a,result);
    	return result;
    }
    
    void pr(v3 const&a){
    	for(v2 const&plane:a){
    		for(v1 const&row:plane){
    			for(int x:row)std::cout<<x;
    			std::cout<<'\n';
    		} std::cout<<'\n';
    	} std::cout<<"=======\n";
    }
    
    // given a v2, return something with its size but all zeroes.
    v2 zero(v2 x){x.assign(x.size(),v1(x[0].size())); return x;}
    v3 pad (v3 x){// pad left and right with an all-zero v2.
    	x.insert(x.begin(),zero(x[0]));//at begin
    	x.push_back(x[0]);//at end-now begin is a zero()
    	return x;}
    v3 trim(v3 x){//the array (x) must not be completely empty
    	auto it=x.begin();auto p0=zero(x[0]);
    	while(p0==*it)++it;
    	x.erase(x.begin(),it);
    	while(x.back()==p0)x.pop_back();
    	return x;
    }
    
    template<class Fn,Fn f>v3 ap3d(v3 a){ // apply for all 3 dimensions
    	a=f(a); // x y z -> [x] y z
    	a=zipeach(a); // [x] z y
    	a=zip(f(zip(a))); // [x] [z] y
    	a=zipeach(a); // [x] y [z]
    	a=zip(f(zip(a))); // [x] [y] [z]
    	return a;
    }
    auto pad3d =ap3d<decltype(&pad),&pad>;
    auto trim3d=ap3d<decltype(&trim),&trim>;
    
    std::vector<v3> expand(std::vector<v3> cubes){
    	std::vector<v3> result;
    	for(v3&cube:cubes){
    		cube = pad3d(std::move(cube));
    		size_t const nx=cube.size(),ny=cube[0].size(),nz=cube[0][0].size();
    		for(size_t x=nx;x-->0;)
    		for(size_t y=ny;y-->0;)
    		for(size_t z=nz;z-->0;){
    			if(cube[x][y][z])continue;
    			if(
    				(x&&cube[x-1][y][z])||(x!=nx-1&&cube[x+1][y][z])||
    				(y&&cube[x][y-1][z])||(y!=ny-1&&cube[x][y+1][z])||
    				(z&&cube[x][y][z-1])||(z!=nz-1&&cube[x][y][z+1])
    			){
    				result.push_back(cube);
    				result.back()[x][y][z]=true;
    				result.back()=trim3d(std::move(result.back()));
    			}
    		}
    	}
    	return result;
    }
    
    int main() {
    	std::vector<v3> a={{{{1}}}};
    	int n;std::cin>>n;
    	++n;//1-based indexing ==> 0-based indexing
    	--n;while(n-->0){
    		a=expand(a);
    		std::sort(a.begin(),a.end());
    		a.erase(std::unique(a.begin(),a.end()),a.end());
    	}
    	long long ans=0;size_t constexpr NCUBEROT=24;
    	for(auto&cube:a){
    		assert(!cube.empty());
    		auto rots=allrot(std::move(cube));
    		assert(rots.size()==NCUBEROT);
    		++ans;//i==0
    		for(size_t i=1;i<NCUBEROT;++i)
    			ans+=rots[0]==rots[i];
    	}
    	assert(ans%NCUBEROT==0);
    	std::cout<<ans/NCUBEROT<<'\n';
    }
    
    

    Try it online!

    Next sequence. I didn't check what it is, but hopefully easy.

    user202729

    Posted 2017-07-21T15:00:01.030

    Reputation: 14 620

    To the next answerer: is the "28-term linear recurrence" proven? If not, you'll need to verify the results up to n=1001, and for that, you need a program that actually computes the sequence. – NieDzejkob – 2018-03-08T17:07:43.723

    aw, man, the challenge is over :( – Giuseppe – 2018-03-14T21:17:04.813

    @NieDzejkob When OEIS has a formula without something like "conjectured" near it, I see no reason to doubt about it. – Christian Sievers – 2018-03-15T12:11:31.367

    @ChristianSievers Well, "gives a 28-term linear recurrence on his web page" is different from a published paper. – NieDzejkob – 2018-03-15T14:25:32.747

    @NieDzejkob It's from the the person who is the author of everything related to this sequence that is mentioned at the OEIS entry. But yeah, it's not a peer reviewed reult. – Christian Sievers – 2018-03-15T22:24:25.037

    2

    40. Rust, 3416 bytes, A000001

    The rules seem to imply hardcoding the first 1001 cases is fine.

    EDIT: I’m editing this post to give some commenters the chance to adjust their vote on it.

    static COUNT: [i32; 1001] =
    [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2,
    1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4,
    2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1,
    4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1,
    12, 1, 10, 1, 4, 2, 2, 1, 231, 1, 5, 2, 16, 1, 4, 1, 14, 2, 2, 1, 45,
    1, 6, 2, 43, 1, 6, 1, 5, 4, 2, 1, 47, 2, 2, 1, 4, 5, 16, 1, 2328, 2,
    4, 1, 10, 1, 2, 5, 15, 1, 4, 1, 11, 1, 2, 1, 197, 1, 2, 6, 5, 1, 13,
    1, 12, 2, 4, 2, 18, 1, 2, 1, 238, 1, 55, 1, 5, 2, 2, 1, 57, 2, 4, 5,
    4, 1, 4, 2, 42, 1, 2, 1, 37, 1, 4, 2, 12, 1, 6, 1, 4, 13, 4, 1, 1543,
    1, 2, 2, 12, 1, 10, 1, 52, 2, 2, 2, 12, 2, 2, 2, 51, 1, 12, 1, 5, 1,
    2, 1, 177, 1, 2, 2, 15, 1, 6, 1, 197, 6, 2, 1, 15, 1, 4, 2, 14, 1,
    16, 1, 4, 2, 4, 1, 208, 1, 5, 67, 5, 2, 4, 1, 12, 1, 15, 1, 46, 2, 2,
    1, 56092, 1, 6, 1, 15, 2, 2, 1, 39, 1, 4, 1, 4, 1, 30, 1, 54, 5, 2,
    4, 10, 1, 2, 4, 40, 1, 4, 1, 4, 2, 4, 1, 1045, 2, 4, 2, 5, 1, 23, 1,
    14, 5, 2, 1, 49, 2, 2, 1, 42, 2, 10, 1, 9, 2, 6, 1, 61, 1, 2, 4, 4,
    1, 4, 1, 1640, 1, 4, 1, 176, 2, 2, 2, 15, 1, 12, 1, 4, 5, 2, 1, 228,
    1, 5, 1, 15, 1, 18, 5, 12, 1, 2, 1, 12, 1, 10, 14, 195, 1, 4, 2, 5,
    2, 2, 1, 162, 2, 2, 3, 11, 1, 6, 1, 42, 2, 4, 1, 15, 1, 4, 7, 12, 1,
    60, 1, 11, 2, 2, 1, 20169, 2, 2, 4, 5, 1, 12, 1, 44, 1, 2, 1, 30, 1,
    2, 5, 221, 1, 6, 1, 5, 16, 6, 1, 46, 1, 6, 1, 4, 1, 10, 1, 235, 2, 4,
    1, 41, 1, 2, 2, 14, 2, 4, 1, 4, 2, 4, 1, 775, 1, 4, 1, 5, 1, 6, 1,
    51, 13, 4, 1, 18, 1, 2, 1, 1396, 1, 34, 1, 5, 2, 2, 1, 54, 1, 2, 5,
    11, 1, 12, 1, 51, 4, 2, 1, 55, 1, 4, 2, 12, 1, 6, 2, 11, 2, 2, 1,
    1213, 1, 2, 2, 12, 1, 261, 1, 14, 2, 10, 1, 12, 1, 4, 4, 42, 2, 4, 1,
    56, 1, 2, 1, 202, 2, 6, 6, 4, 1, 8, 1, 10494213, 15, 2, 1, 15, 1, 4,
    1, 49, 1, 10, 1, 4, 6, 2, 1, 170, 2, 4, 2, 9, 1, 4, 1, 12, 1, 2, 2,
    119, 1, 2, 2, 246, 1, 24, 1, 5, 4, 16, 1, 39, 1, 2, 2, 4, 1, 16, 1,
    180, 1, 2, 1, 10, 1, 2, 49, 12, 1, 12, 1, 11, 1, 4, 2, 8681, 1, 5, 2,
    15, 1, 6, 1, 15, 4, 2, 1, 66, 1, 4, 1, 51, 1, 30, 1, 5, 2, 4, 1, 205,
    1, 6, 4, 4, 7, 4, 1, 195, 3, 6, 1, 36, 1, 2, 2, 35, 1, 6, 1, 15, 5,
    2, 1, 260, 15, 2, 2, 5, 1, 32, 1, 12, 2, 2, 1, 12, 2, 4, 2, 21541, 1,
    4, 1, 9, 2, 4, 1, 757, 1, 10, 5, 4, 1, 6, 2, 53, 5, 4, 1, 40, 1, 2,
    2, 12, 1, 18, 1, 4, 2, 4, 1, 1280, 1, 2, 17, 16, 1, 4, 1, 53, 1, 4,
    1, 51, 1, 15, 2, 42, 2, 8, 1, 5, 4, 2, 1, 44, 1, 2, 1, 36, 1, 62, 1,
    1387, 1, 2, 1, 10, 1, 6, 4, 15, 1, 12, 2, 4, 1, 2, 1, 840, 1, 5, 2,
    5, 2, 13, 1, 40, 504, 4, 1, 18, 1, 2, 6, 195, 2, 10, 1, 15, 5, 4, 1,
    54, 1, 2, 2, 11, 1, 39, 1, 42, 1, 4, 2, 189, 1, 2, 2, 39, 1, 6, 1, 4,
    2, 2, 1, 1090235, 1, 12, 1, 5, 1, 16, 4, 15, 5, 2, 1, 53, 1, 4, 5,
    172, 1, 4, 1, 5, 1, 4, 2, 137, 1, 2, 1, 4, 1, 24, 1, 1211, 2, 2, 1,
    15, 1, 4, 1, 14, 1, 113, 1, 16, 2, 4, 1, 205, 1, 2, 11, 20, 1, 4, 1,
    12, 5, 4, 1, 30, 1, 4, 2, 1630, 2, 6, 1, 9, 13, 2, 1, 186, 2, 2, 1,
    4, 2, 10, 2, 51, 2, 10, 1, 10, 1, 4, 5, 12, 1, 12, 1, 11, 2, 2, 1,
    4725, 1, 2, 3, 9, 1, 8, 1, 14, 4, 4, 5, 18, 1, 2, 1, 221, 1, 68, 1,
    15, 1, 2, 1, 61, 2, 4, 15, 4, 1, 4, 1, 19349, 2, 2, 1, 150, 1, 4, 7,
    15, 2, 6, 1, 4, 2, 8, 1, 222, 1, 2, 4, 5, 1, 30, 1, 39, 2, 2, 1, 34,
    2, 2, 4, 235, 1, 18, 2, 5, 1, 2, 2, 222, 1, 4, 2, 11, 1, 6, 1, 42,
    13, 4, 1, 15, 1, 10, 1, 42, 1, 10, 2, 4, 1, 2, 1, 11394, 2, 4, 2, 5,
    1, 12, 1, 42, 2, 4, 1, 900, 1, 2, 6, 51, 1, 6, 2, 34, 5, 2, 1, 46, 1,
    4, 2, 11, 1, 30, 1, 196, 2, 6, 1,10,1,2,15,199];
    
    fn count(i: usize) -> i32 { COUNT[i] }
    

    Try it online!

    Next sequence.

    Lynn

    Posted 2017-07-21T15:00:01.030

    Reputation: 55 648

    16Hardcoding in a language as dedicated to computation as rust... you earned my downvote. – Leaky Nun – 2017-07-22T11:22:01.663

    2"Voting up a question or answer signals to the rest of the community that a post is interesting, well-researched, and useful, while voting down a post signals the opposite: that the post contains wrong information, is poorly researched, or fails to communicate information." I wouldn't necessarily upvote this because hardcoding isn't interesting but I don't think it deserves downvotes just because it isn't a creative solution – Poke – 2017-07-28T18:32:35.353

    6Note that counting finite groups of order n is a highly non-trivial problem, and any serious attempt to write an answer here that isn’t O(silly(n)) would take hours/days of coding, and get beaten to it by some bullshit Mathematica-oid that has a built-in for it, which, surprise, absolutely would cache the first 1001 cases too. – Lynn – 2017-07-28T18:55:45.557

    Well then, seeing your point I will reverse my downvote, but apparently I can't un-downvote until this post is edited again. – user41805 – 2017-07-28T19:35:09.060

    I see your point with that, and though I don't like having languages being "wasted" to downvotes, I do see your point with the built-ins. If you edit the post I'll revert my downvote. – HyperNeutrino – 2017-07-30T00:10:06.827

    @Cowsquack and HyperNeutrino: I’ve edited the post – Lynn – 2017-07-30T17:42:35.240

    2

    63. Haxe, 108 bytes, A000057

    function(a,n=3){while(a>0){var i=0,x=0,y=1,z;while(y>0&&i++<=n){z=x+y;x=y;y=z%n;}i==n++&&a-->0;}return n-1;}
    

    Test it online!

    Next sequence

    ETHproductions

    Posted 2017-07-21T15:00:01.030

    Reputation: 47 880

    @geokavel Sorry, I keep forgetting to do that... :P – ETHproductions – 2017-07-22T22:55:28.827

    Aww crud and I had the Catalan numbers ready for cQuents, but I used it for Fibonacci instead :/ – Stephen – 2017-07-22T22:58:37.020

    2

    83. Bash, 53+165265=165318, A000014

    #!/bin/sh
    read index
    head -"$index" a.txt | tail -1
    

    requires that a.txt (https://hastebin.com/eroterefov) be in the same directory

    next sequence

    Also, this is my first post to the Code Golf Stack Exchange, please let me know if I messed up in any way.

    Husnain Raza

    Posted 2017-07-21T15:00:01.030

    Reputation: 329

    Welcome to PPCG! – Martin Ender – 2017-07-25T05:32:18.703

    Wouldn't the next sequence be A165318?

    – Skidsdev – 2017-07-25T08:15:24.460

    This would be an invalid answer, correct? – Husnain Raza – 2017-07-27T04:35:12.860

    @HusnainRaza It is, but nothing good will come from deleting an answer this far from the end of the chain. – Dennis – 2017-07-28T16:32:43.710

    If the values of the next current sequence (A000066) are not even known past n=13, how is one supposed to write a program to calculate them? – Husnain Raza – 2017-07-28T18:05:35.067

    2

    84. Boo, 330 bytes, A165318

    def f (n):
      cnt = 0
      i   = 1
      while true:
        i++
        isPrime = true
        for k in range(2, i):
          if i%k==0: isPrime = false
        if isPrime == false: continue
        divs = 0
        q    = i-1
        for k in range(1, i):
          if q%k == 0: divs = divs+1
        if (divs & (divs - 1)) != 0: continue
        if cnt == n: return i
        cnt++
    

    Try it online!

    Next sequence

    BlackCap

    Posted 2017-07-21T15:00:01.030

    Reputation: 3 576

    1

    cQuents code for next sequence (lang already used): $0:z+$^2

    – Stephen – 2017-07-25T12:48:00.840

    2

    85. TypeScript, 97 bytes, A000330

    function f(i:number) {
     let s:number=0;
     for(let j:number=0;j<=i;j++){
      s+=j**2;
     }
     return s;
    }
    

    Try it online!

    Next Sequence

    Stephen

    Posted 2017-07-21T15:00:01.030

    Reputation: 12 293

    1Back to partitions again? Fine... – caird coinheringaahing – 2017-07-25T13:15:43.670

    @cairdcoinheringaahing sorry :P – Stephen – 2017-07-25T13:15:51.617

    2

    88. Go, 386 bytes, A000016

    For those using graduation script, SE translates tabs into spaces.

    import . "math"
    func gcd (a, b int) int {
        for b != 0 { c := b; b = a % b; a = c }
        return a
    }
    func phi (n int) int{
        r := 1
        for i := 2; i < n; i++ { if gcd (i, n) == 1 { r++ } }
        return r
    }
    func f (n int) int {
        s := 0.
        for i := 1; i <= n; i++ {
            if (i % 2 == 1) && (n % i == 0) {
                s += (float64(phi(i)) * Pow(2., float64(n) / float64(i))) / float64(2 * n)
            }
        }
        return int(s)
    }
    

    Try it online!

    Next Sequence.

    Uriel

    Posted 2017-07-21T15:00:01.030

    Reputation: 11 708

    1

    Can anybody explain the difference between all these sequences with the same name but different values? A000033, A000159, A000181, A000185, A000222, A000386, A000425, A000426, A000450, A058085, A058086, A058089, A058090

    – Engineer Toast – 2017-07-25T16:22:22.963

    @EngineerToast the difference is the offset (what that means exactly I dunno) – Stephen – 2017-07-25T16:40:54.357

    @StepHen Ah, thanks! I hadn't noticed that. These tables may prove relevant, then. I believe the coefficients on OEIS are given in the form k,n. I think they're related to seating couples at a table.

    – Engineer Toast – 2017-07-25T17:29:13.797

    2

    92. Thue, 93 bytes, A001733

    0::=~7
    1::=0
    2::=0
    3::=~10
    4::=aa
    5::=~12
    6::=~13
    7::=~21
    8::=aaa
    9::=88a
    a::=~1
    b::=:::
    ::=
    b
    

    This does hardcode the values, but that shouldn't be a problem, as it is not possible to encode a number in base -1.

    Next sequence

    pppery

    Posted 2017-07-21T15:00:01.030

    Reputation: 3 987

    17 in base -1 is 1010101010101 – HyperNeutrino – 2017-07-31T00:26:13.540

    How is that true? – pppery – 2017-07-31T00:28:01.250

    The n+1-th last digit has place value -1 ** n, so since -1 ** n is -1 if n%2 else 1, every other digit is 1 (technically that's not in the sequence so you're not wrong :P but just being a nitpick xD) – HyperNeutrino – 2017-07-31T00:36:09.980

    2

    94. Befunge 93, 27 bytes, A000035

    >  &   v
    v  2   <
    >  % . @@
    

    Try it online!

    Next Sequence... How about a REALLY easy one??? :P

    Golfed solution: &2%.@

    HyperNeutrino

    Posted 2017-07-21T15:00:01.030

    Reputation: 26 575

    cQuents for A000027: $ (1-indexed) – Stephen – 2017-07-31T00:48:24.277

    @StepHen Jelly and Anyfix for A000027: – HyperNeutrino – 2017-07-31T00:49:36.707

    2

    96. Common Lisp, 236 bytes, A000478

    (defun power(m n)
      (let ((result 1))
        (dotimes (count n result)
                 (setf result (* m result)))))
    (defun solve(n) (+ (- (/ (+ 7 n (* (+ 6 n) (+ 6 n))) 2) (* (+ .5 (/ (+ 6 n) 4)) (power 2 (+ 5 n)))) (/ (power 3 (+ 6 n)) 6)))
    

    Try it online!

    Some code copied from this StackOverflow question. This is a trivial conversion of the formula specified in the comments of the sequence into lisp.

    Next sequence

    pppery

    Posted 2017-07-21T15:00:01.030

    Reputation: 3 987

    Perhaps I'm disobeying my own advice, but the next sequence shouldn't be too hard. – pppery – 2017-07-31T01:52:43.933

    Max Alekseyev, can we get a formula that's not just >=? xD – Stephen – 2017-07-31T02:01:44.980

    @StepHen You're twelve years too late to ask ... – pppery – 2017-07-31T02:07:51.113

    5@StepHen Why don't you just do what the original researchers did, and write an exhaustive search program on IBM S/360 cards? – KSmarts – 2017-07-31T17:00:00.443

    @ppperry, there's no way to do A000236. Its description doesn't tell us anything. Maximum m such that there are no two adjacent elements belonging to the same n-th power residue class modulo some prime p in the sequence 1,2,...,m (equivalently, there is no n-th power residue modulo p in the sequence 1/2,2/3,...,(m-1)/m). Its formula is completely useless. a(n) >= 2^n - 1 I don't want to start a rollback war, so if you'd like to kill the challenge completely, go ahead. – MD XF – 2017-08-01T21:47:39.510

    6@MDXF The papers in the "links" section provide more information. There doesn't appear to be a simple way to do it (with the algorithm I'm working on, I doubt more than the first 2 or 3 terms will fit in TiO's time limit), but it's not impossible. – KSmarts – 2017-08-02T14:34:33.397

    2

    99. Spaced, 30 bytes, A000153

    $<2?$: $*f($-1) + ($-2)*f($-2)
    

    Try it online!

    Next sequence

    Business Cat

    Posted 2017-07-21T15:00:01.030

    Reputation: 8 927

    2

    103. VB6, 713 bytes, A000158

    Function A000158(ByVal n As Long) As Long
        Dim x1 As Long, x2 As Long, x3 As Long
        A000158 = 0
        n = n + 3
    
        x1 = 1
        x2 = 1
        x3 = 1
        While x1 ^ (2 / 3) + x2 ^ (2 / 3) + x3 ^ (2 / 3) <= n ' x1
            While x1 ^ (2 / 3) + x2 ^ (2 / 3) + x3 ^ (2 / 3) <= n ' x2
                While x1 ^ (2 / 3) + x2 ^ (2 / 3) + x3 ^ (2 / 3) <= n ' x3
                    A000158 = A000158 + 1
                    x3 = x3 + 1
                Wend ' x3
                x2 = x2 + 1
                x3 = x2
            Wend ' x2
            x1 = x1 + 1
            x2 = x1
            x3 = x2
        Wend ' x1
    
        ' no need to return; VB6 will return the value of the variable A000158 (same name as the function)
    End Function
    

    Next Sequence

    This is a function which takes n as an input and returns a value back to the caller. Used in the manner of answer = A000158(input).

    VB6 shares a lot of the syntax with VB.NET, but use completely different compilers (and some different syntaxes).

    VB6 longs are actually 32 bit integers.

    Unlike C based languages, the / is floating point division. Integer division is handled by \. So 1 / 2 will give 0.5.

    The ^ is actually exponent, and not xor like a lot of languages. I believe Xor is the VB6 xor.

    VB6 has an implicit variable inside their functions that share the same name. So instead of saying Return <value>, you assign the return value to the function name. In this instance, I set the variable A000158 with my return value. After execution, the value of A000158 is given back to the caller.

    Example usage:

    I created a new form in the VB6 IDE, dropped two text boxes and a button in it (didn't change the form field names).

    Private Sub Command1_Click()
        Text2.Text = A000158(Text1.Text)
    End Sub
    
    Function A000158(ByVal n As Long) As Long
        Dim x1 As Long, x2 As Long, x3 As Long
        A000158 = 0
        n = n + 3
    
        x1 = 1
        x2 = 1
        x3 = 1
        While x1 ^ (2 / 3) + x2 ^ (2 / 3) + x3 ^ (2 / 3) <= n ' x1
            While x1 ^ (2 / 3) + x2 ^ (2 / 3) + x3 ^ (2 / 3) <= n ' x2
                While x1 ^ (2 / 3) + x2 ^ (2 / 3) + x3 ^ (2 / 3) <= n ' x3
                    A000158 = A000158 + 1
                    x3 = x3 + 1
                Wend ' x3
                x2 = x2 + 1
                x3 = x2
            Wend ' x2
            x1 = x1 + 1
            x2 = x1
            x3 = x2
        Wend ' x1
    
        ' no need to return; VB6 will return the value of the variable A000158 (same name as the function)
    End Function
    

    Type a value into TextBox1, hit the Button1, and watch TextBox2 get populated by the result.

    Brian J

    Posted 2017-07-21T15:00:01.030

    Reputation: 653

    2

    105. Windows Batch, 193, A000267

    @echo off
    
    :SquareRoot number
    
    set /A number=4 * %1 + 1, last=2, sqrt=number/last
    :nextIter
       set /A last=(last+sqrt)/2, sqrt=number/last
    if %sqrt% lss %last% goto nextIter
    echo %last%
    

    Next sequence

    Takes the input number as a command line argument, and prints the result.

    Run by saving the above as a .bat file, and execute with windows command prompt (if anyone knows of an online interpreter, I'm happy to update).

    Uses an iterative method of computing square roots (Newton's method, I think?). It finds the floor of the square root, which is just what we need for this sequence.

    Brian J

    Posted 2017-07-21T15:00:01.030

    Reputation: 653

    2

    106. Objective-C (clang), 45 + 2 = 47 bytes, A000193

    int f(int x){ return (int) round(log(x+1)); }
    

    Try it online!

    I don't really know Objective-C, but I got something working. Needs the -lm flag (no clue why, but it doesn't work without it).

    Does what it says on the tin - rounds the log of the input. Note that it adds 1 to the input to make the sequence 0-indexed.

    Next Sequence

    Stephen

    Posted 2017-07-21T15:00:01.030

    Reputation: 12 293

    2The -lm flag would be to link against libm, which contains log. I base this explanation entirely on pain I've experienced in the past when figuring out how to compile C programs. – Peter Taylor – 2017-08-14T16:23:59.227

    2

    Note for the next sequence (particularly for people who can see comments on the self-deleted attempt): courtesy of http://www.jpr2718.org/pell.pdf , when searching for solutions to x^2 - 2y^2 = N it suffices to consider 0 <= 2y^2 <= N, so x^2 <= 2N. This is a consequence of the smallest non-trivial solution to x^2 - 2y^2 = 1 being (3, 2).

    – Peter Taylor – 2017-08-14T18:45:47.797

    Why was the attempt deleted? – NieDzejkob – 2017-08-14T19:22:56.820

    @NieDzejkob Something with int overflow - screencap of comments on deleted answer

    – Stephen – 2017-08-14T19:25:03.237

    Uh, is there a language that uses BigInts as it's primary type? I only know Haskell, but it has been used already – NieDzejkob – 2017-08-14T20:24:28.717

    @NieDzejkob I know Python/Ruby and any esolangs written in them use arbitrary precision integers by default. You could also just import a BigInt package in, say, Java. – Stephen – 2017-08-14T20:25:33.087

    2

    109. brainfuck, 81 bytes, A000032

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

    Try it online!

    Input with raw bytes, or Unicode codepoints, whatever your interpreter supports. Requires large cells for larger inputs. TIO uses Python with an interpreter modified to do input in numbers instead of raw bytes to make testing easier. I probably could golf it down further, but I'm lazy.

    Next sequence!

    NieDzejkob

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 630

    Is it really BF if you change how input works? :P – Stephen – 2017-08-15T17:41:26.680

    @StepHen I changed it only for convenience, officially I just used base 256 instead of 10 for I/O. – NieDzejkob – 2017-08-15T17:49:27.503

    2

    117. Rail, 106 bytes, A001156

    $'g'
     -13{f}#
    $'f'
     \  /(y)(x){f}(z)(y)s(y)(x)-@
      -*(!z!)(!y!)(!x!)(y)(x)g<
     @-(z)a2(z)a{f}a----#-q0(x)-@
    

    The function named g defined at the top is the function that computed the sequence. f is a helper function that you shouldn't call directly.

    Try it online!

    Next Sequence (more math! Yay!)

    pppery

    Posted 2017-07-21T15:00:01.030

    Reputation: 3 987

    2

    118. Ly, 128 bytes, A000106

    1<n
    [>&sy0>lr>l
     [&s>lrysp>l[:lf%:[pp0f10]p![p:0]p1-]p
      <<<0>>[sp>l*sp<<<l+>>]
      <p<*sp<l+>>]
     <<f/<1-]
    >&s>lr[sp<l*sp<l+>>]<<u
    

    Next sequence

    Try it online!

    Easy: just compute values for 1 to n+1 of A000081, then convolve. You may notice that I'm not using Ly's indexing operator I, I'm more thinking in terms of what Haskell calls zipWith. It's a pitty that the division makes Ly use floating point.

    The next sequence is a bit simple, I apologize.

    Christian Sievers

    Posted 2017-07-21T15:00:01.030

    Reputation: 6 366

    2

    119. bc, 139 bytes, A000128

    Next Sequence

    define f(x) {
    	a = 0
    	b = 1
    	for (i=0; i<x; ++i) {
    		aux = b
    		b = a + b
    		a = aux
    	}
    	return a
    }
    n = read()
    f(n+5) - (n+1) * (n+2) / 2 - 3
    

    Try it online!

    Felipe Nardi Batista

    Posted 2017-07-21T15:00:01.030

    Reputation: 2 345

    1If only I had known that such a nice language was still available... – Christian Sievers – 2017-08-22T14:53:56.877

    2

    120. MATL, 22 bytes, A000139

    ttQ:pw2*Q:p*3G*:p2*w/&
    

    Next Sequence

    Try it online!

    Cinaski

    Posted 2017-07-21T15:00:01.030

    Reputation: 1 588

    5How the heck was MATL not taken yet? – Scott Milner – 2017-08-23T21:29:14.467

    @ScottMilner MATLAB is also free, somehow. – Business Cat – 2017-08-24T17:40:16.327

    2@BusinessCat As is Maple. In that case, people may just be avoiding the accusation that they copied the code from the OEIS. – KSmarts – 2017-08-24T18:12:28.597

    @KSmarts I've been tempted several times, though... – Scott Milner – 2017-08-24T18:49:20.217

    Since PyPy is considered a separate language, C (tcc) and C (clang) are untaken. – NieDzejkob – 2017-08-26T16:48:36.680

    Next sequence also has Mathematica code for someone who has an unused version of it (Mathematica 11?) – Husnain Raza – 2017-08-26T21:06:15.310

    @HusnainRaza I don't see any mathematica code on that page, are you sure? – NieDzejkob – 2017-08-27T21:52:32.770

    @NieDzejkob this was for a000022 – Husnain Raza – 2017-08-28T01:18:25.523

    @KSmarts I would rather the chain was continued than you using the OEIS code. – caird coinheringaahing – 2017-08-29T14:37:33.460

    2

    125. BeanShell, 655 bytes, A000796

    import java.math.*;I=new Scanner(System.in).nextInt();D=I+9;O=BigDecimal.ONE;T=O.add(O);N=BigDecimal.TEN;C=new MathContext(2*D,RoundingMode.HALF_DOWN);z(a,b){return a.subtract(b,C).abs(C).compareTo(O.divide(N.pow(D,C)))>-1;}bsqrt(c){x=O;do{x=x.add(x.pow(2,C).add(c.negate(C),C).divide(x.multiply(T,C),C).negate(C),C);}while(z(x.pow(2,C),c));return x;}s=BigDecimal.ZERO;a=O;b=bsqrt(T);for(int i=1;z(a,b);i++){g=a.multiply(b,C);a=a.add(b,C).divide(T,C);b=bsqrt(g);s=s.add(T.pow(i,C).multiply(a.pow(2,C).subtract(g,C),C),C);}print(T.multiply(a.pow(2,C),C).divide(O.subtract(s,C),C).multiply(N.pow(I,C),C).toBigInteger().remainder(BigInteger.TEN).toString());
    

    Try it online!

    Next sequence! (easy sequence again)

    BeanShell is just an interpreted Java with weak typing, so a high byte count is expected. I probably could golf it more by omitting the MathContext in some BigDecimal calls, but this would have to be tested empirically, which, with the probability of introducing inaccuracies for higher inputs is, in my opinion, not worth the risk. Also prints the input for some reason. This is probably unfixable: input test on TIO.

    Square root implementation heavily based on this stackoverflow answer, the pi calculation itself on this Python + mpmath article.

    NieDzejkob

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 630

    2

    126. Scala, 156 bytes, A000655

    object Main extends App{
    	val a=Console.readInt
    	if (a == 0) { print(1) }
    	else if (a == 1) { print(3) }
    	else if (a == 2) { print(5) }
    	else { print(4) }
    }
    

    Try it online!

    Next Sequence

    Stephen

    Posted 2017-07-21T15:00:01.030

    Reputation: 12 293

    2

    128. Groovy, 82 bytes, A000058

    def a
    a = { n,i=0G,x=2G -> 
    	if (i == n) {
    		x
    	} else {
    		a(n,i+1G,x*x-x+1G)
    	}
    }
    

    The Gs indicate BigIntegers. Simple recursive implementation that counts from a(0) to a(n).

    Try it online!

    Next Sequence

    Stephen

    Posted 2017-07-21T15:00:01.030

    Reputation: 12 293

    D: you monster! My language! +1 – Magic Octopus Urn – 2017-09-06T19:44:26.243

    a={n,i=0G,x=2G->(i==n)?x:a(n,i+1G,x*x-x+1G)}. I love groovy so much O_O ;_;. I'd KILL for it to be slightly more competitive. – Magic Octopus Urn – 2017-09-06T20:10:16.817

    @MagicOctopusUrn JS is basically the same, just shorter but without the arbitrary precision, and Python is basically the same, but longer because of lambda and no ?: – Stephen – 2017-09-06T20:26:49.307

    2

    135. Husk, 29 bytes, A000277

    *1*1*1*1*1*1*1+5-*2⌊√+5*4⁰*3⁰
    

    Try it online!

    Next Sequence.

    Mr. Xcoder

    Posted 2017-07-21T15:00:01.030

    Reputation: 39 774

    2

    136. A Pear Tree, 232 bytes, A000029

    The program contains unprintable characters, so here is the xxd:

    00000000: 7573 6520 4d61 7468 3a3a 4e75 6d53 6571  use Math::NumSeq
    00000010: 3a3a 546f 7469 656e 743b 7573 6520 504f  ::Totient;use PO
    00000020: 5349 583b 246e 203d 2069 6e74 2824 5f29  SIX;$n = int($_)
    00000030: 3b69 6628 246e 297b 2474 203d 204d 6174  ;if($n){$t = Mat
    00000040: 683a 3a4e 756d 5365 713a 3a54 6f74 6965  h::NumSeq::Totie
    00000050: 6e74 2d3e 6e65 7728 293b 666f 7228 2464  nt->new();for($d
    00000060: 203d 2031 3b24 6420 3c3d 2024 6e3b 2464   = 1;$d <= $n;$d
    00000070: 2b2b 297b 6966 2821 2824 6e20 2520 2464  ++){if(!($n % $d
    00000080: 2929 7b24 7320 2b3d 2024 742d 3e69 7468  )){$s += $t->ith
    00000090: 2824 6e2f 2464 292a 322a 2a28 2464 293b  ($n/$d)*2**($d);
    000000a0: 7d7d 7072 696e 7420 2473 2f28 322a 246e  }}print $s/(2*$n
    000000b0: 292b 2824 6e25 322b 3329 2f34 2a32 2a2a  )+($n%2+3)/4*2**
    000000c0: 666c 6f6f 7228 246e 2f32 293b 7d65 6c73  floor($n/2);}els
    000000d0: 657b 7072 696e 7420 313b 7d65 7869 7423  e{print 1;}exit#
    000000e0: 8025 6b1b 0000 0000                      .%k.....
    

    The bit at the end is just to have a CRC of 0, the rest is standard perl.

    No TIO link because it uses the Math::NumSeq::Totient which isn't installed on TIO.

    Next sequence!

    NieDzejkob

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 630

    2

    140. MATLAB, 918 bytes, A000052

    function q = intToNum(N)
    function o = g(N)
    n=[0,1,2,3,4,5,6,7,8,9,10+(0:9),(2:9)*10];
    e={'zero';'one';'two';'three';'four';'five';'six';'seven';'eight';'nine';'ten';'eleven';'twelve';'thirteen';'fourteen';'fifteen';'sixteen';'seventeen';'eighteen';'nineteen';'twenty';'thirty';'forty';'fifty';'sixty';'seventy';'eighty';'ninety'};
        if N<=20
          o=e{N+1};
        elseif N<100
          if mod(N,10)==0
            s='';
          else
            s=g(mod(N,10));
          end
          o=strcat(e{(N-mod(N,10))==n},s);
        elseif N<1000
          if mod(N,100)==0
            s='';
          else
            s=g(mod(N,100));
          end
          o=strcat(g(floor(N/100)),'hundred',s);
        elseif N>=1000
          o=strcat(g(floor(N/1000)),'thousand',g(mod(N,1000)));
    end
    end
    [~,I]=sort(arrayfun(@g,0:9,'un', 0));
    R=0:9;
    R=R(I);
    S=10:99;
    [~,I]=sort(arrayfun(@g,S,'un',0));
    R=[R,S(I)];
    S=100:999;
    [~,I]=sort(arrayfun(@g,S,'un',0));
    R=[R,S(I)];
    q=R(N);
    end
    

    Try it online!

    next sequence

    To run properly in matlab, this needs to be saved as intToNum.m which is +10 bytes. However, this should also work in Octave with minor modifications (as in the TIO link)

    Giuseppe

    Posted 2017-07-21T15:00:01.030

    Reputation: 21 077

    1I was a moment away from posting an answer in Erlang :( IT'S FUNCTIONAL. DO YOU KNOW HOW FRUSTRATING THAT WAS? +1 anyway – NieDzejkob – 2017-09-06T19:32:11.523

    @NieDzejkob yeah sorry about that...at least you'll be set for, oh, I don't know, this sequence, if Erlang hasn't been used up by then...

    – Giuseppe – 2017-09-06T19:39:31.830

    Does round round or floor? Because if it rounds then it looks like it will give incorrect results. I always generate the sequence up to a 1000 (or as far as you can reasonably go) and I compare it with the txt files from the OEIS. Did you? – NieDzejkob – 2017-09-06T19:45:34.217

    @NieDzejkob oh good call. I fixed that and a couple things and triple-checked the output. This is definitely correct now (and the spacing allowed me to fudge a bit to keep the byte count the same). – Giuseppe – 2017-09-06T20:10:43.207

    2

    141. MOO, 39 bytes, A000918

    return $math_utils:pow(2,args[1])-1-1-0
    

    Next sequence

    pppery

    Posted 2017-07-21T15:00:01.030

    Reputation: 3 987

    Oh lawd, you get 2^n-2 and give the next person THAT? I've been 1 minute late to the easy party like 9 times on this one. I mean not hard... But difficult in Groovy the one language I wanted to use xD. – Magic Octopus Urn – 2017-09-06T19:23:20.117

    @MagicOctopusUrn Oh come on, it's really not that hard. – Mr. Xcoder – 2017-09-06T19:24:12.003

    @Mr.Xcoder I misread it at first I thought it was the number of primes less than 2^n-1. Still, only sad because groovy is shite at primality. – Magic Octopus Urn – 2017-09-06T19:25:02.623

    1Invalid. alephalpha answered it the 66th time. – Mr. Xcoder – 2017-09-06T19:25:32.737

    @Mr.Xcoder fixed – pppery – 2017-09-06T19:29:03.830

    @MagicOctopusUrn but Groovy was used already – NieDzejkob – 2017-09-06T19:34:45.953

    1

    A00039 is a(2*n) for a(n)=A000025, implemented in Pyth here

    – Giuseppe – 2017-09-06T19:42:45.833

    @NieDzejkob was it by me?!?! cries – Magic Octopus Urn – 2017-09-06T19:44:08.650

    @MagicOctopusUrn no I took it sorry :P – Stephen – 2017-09-06T19:45:25.473

    4I always get MOO and COW confused... – KSmarts – 2017-09-07T02:53:51.020

    2

    142. Erlang (escript), 782 bytes, A000039

    
    p(N) -> lists:usort([lists:sort(E)||E<-f(p(N,N))] ++ [[N]]).
    p(1,_) -> [[1]];
    p(N,M) -> 
        Extra = [ [lists:sort(Y++[X])||Y<-p(N-X,M)] || X<-lists:seq(1,N-1)],
        if N == M -> Extra; true -> [[N]|Extra] end.
    
    f([])  -> [];
    f([H|T]=L) when is_integer(H),is_list(T) ->
        case is_flat(T) of
            true  -> [lists:flatten(L)];
            false -> f([e(H,E) || E <- T]) 
        end;
    f([H|T]) -> f(H) ++ f(T);
    f(H)    -> [H].
    
    e(A,B) when is_list(B) -> [A|B];
    e(_,B) -> B.
    
    is_flat(L) when is_list(L) -> length([E||E<-L, is_list(E)]) < 2;
    is_flat(_) -> true.
    
    rank(P) -> lists:max(P) - length(P).
    
    score(P) -> (1 - abs(rank(P) rem 2)) * 2 - 1.
    
    a(0) -> 1;
    a(N) -> lists:sum(lists:map(fun(P) -> score(P) end, p(N))).
    
    main([])-> {ok, [N]} = io:fread("", "~d"),
    io:fwrite("~p", [a(2*N)]).
    

    Try it online!

    Next sequence!

    Partition function from here.

    NieDzejkob

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 630

    2

    144. Chez Scheme, 68 bytes, A000120

    (define(e n)(cond((< n 1)0)((+(e(fx/ n 2))(remainder n 2)))))       
    

    Try it online!

    Next sequence

    Giuseppe

    Posted 2017-07-21T15:00:01.030

    Reputation: 21 077

    +100 rep if someone does the next one in Beatnik – NieDzejkob – 2017-09-07T16:22:22.677

    2

    145. Phoenix, 271 bytes, A000068

    #https://stackoverflow.com/a/39743570/7605753
    function is_prime(n){for(var $i=n>>1;$i&&n%$i--;);return!$i&&n>1;}
    $n = readline();
    $j = 0;
    $k = 1;
    while (1) {
     $m = pow($k, 4) + 1;
     if (is_prime($m)) {
      if ($j == $n) {
       echo $k;
       exit();
      }
      $j += 1;
     }
     $k += 1;
    }
    

    Try it online!

    Next Sequence

    Stephen

    Posted 2017-07-21T15:00:01.030

    Reputation: 12 293

    2

    146. PicoLisp, 121 bytes, A000271

    (de a (n) (cond ((= n 0) 1) ((< n 3) 0) ((< n 4) 1) (T (+ (* (- n 1) (a (- n 2))) (* (- n 1) (a (- n 1))) (a (- n 3))))))
    

    Next Sequence

    Try it online!

    I also implemented A000179 in PicoLisp to try and do sums on it, but this was faster.

    I'm running out of Lisp variants to work on!

    Giuseppe

    Posted 2017-07-21T15:00:01.030

    Reputation: 21 077

    2@Stephen I stand corrected. – Giuseppe – 2017-09-07T21:24:13.083

    2

    153. Emojicode, 1344 bytes, A000136

    
      Find the index of e in the list by comparing the elements with c
     e Element cElement Element➡➡
      i⏩0 c eii
      ⚡
     
    
    
    ☯
      Checks whether a permutation is a possible way to fold stamps
     p➡
      k⏩0➖p 1
       r⏭k 2➖p 1 2
        cab➡a b
        Ap k c
        Bp r c
        Cp➕k 1 c
        Dp➕r 1 c
        ◀A B◀B C◀C D◀B C◀C D◀D A◀C D◀D A◀A B◀D A◀A B◀B C
       
      
      
     
    
      Iterates over the permutations
     n➡
      an
      cn
      i⏩0 n
       a i i
       c i 0
      
    
      i 0
      r 1
      ◀i n
       ◀c i i
        j 0
        i 2 1jc i
        ta j
        a ja i
        a i t
        ☯a➕r 1
        c i➕1c i
        i 0
       
        c i 0
        ➕i 1
       
      
      r
     
    
    
    
     i10
      ☯➕1 i 10
     
    
    

    Try it online!

    Next sequence!

    I was going to use something esoteric, but then I changed my mind. Pretty self explanatory, I don't think an explanation is necessary.

    Note: for inputs larger than 7, you have to specify a heap size larger than 512 MB during the compilation of the Real-Time Engine. For example, use cmake .. -DheapSize=1073741824 for 1 GB. If you run out of heap space, the VM segfaults, probably because someone does not check for NULL after malloc.

    Edit: make this faster and less memory-hungry. Now I wonder whether the garbage collector is working properly

    Edit almost 2 months later: this code had to work around a bug in the implementation of the ⏩ type. Now that this bug is fixed and TIO updated, I had to offset the range parameters again. I also managed to add some comments, all while keeping the bytecount the same.

    NieDzejkob

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 630

    It segfaults for n=7? oookay. – Giuseppe – 2017-09-12T00:10:25.380

    ... which makes this answer invalid. – pppery – 2017-09-12T01:26:57.603

    @ppperry "fixed" – NieDzejkob – 2017-09-12T05:36:01.263

    7This isn't at all self-explanatory. – Peter Taylor – 2017-09-12T10:31:33.880

    I was going to use something esoteric o_o You don't consider Emojicode esoteric?! – totallyhuman – 2017-09-12T11:57:07.580

    2@INCOMING Emoji (the stack based language) is definitely esoteric, but Emojicode is object oriented and stuff. Believe it or not, but there is real software written in Emojicode, ~~in contrast to Haskell~~. – NieDzejkob – 2017-09-12T12:44:51.423

    @NieDzejkob So Emojicode is a "normal" language with esoteric syntax? – KSmarts – 2017-09-12T13:32:10.177

    @KSmarts I'd say "uncommon" and it's more about the vocabulary rather than syntax. – NieDzejkob – 2017-09-12T13:46:35.457

    2

    157. C (gcc), 376 bytes, A002466

    int f(int n)
    {
        int i = 0, s[100] = {0};
        s[0] = 1;
        s[1] = 1;
        s[2] = 2;
    
        while (i < 97) {
            if ((i % 5) == 3) {
                s[3+i] = s[i] + s[2+i];
            }
            else if ((i % 5) == 4) {     
                s[3+i] = s[1+i] + s[2+i];
            }
            else {
                s[3+i] = s[i] + s[1+i] + s[2+i];
            }
            i++;
        }
    
        return s[n];
    }
    

    It's like an obnoxious Fibonacci! 0-indexed.

    Next sequence

    Try it online!

    The function for this sequence said this:

    a(1) = a(2) = 1, a(3) = 2, a(5*k+2) = a(5*k+1) + a(5*k-1), a(5*k+3) = a(5*k+2) + a(5*k+1), a(5*k+b) = a(5*k+b-1) + a(5*k+b-2) + a(5*k+b-3) for b=-1,0,1
    

    It's completely unhelpful. However, I noticed that the integers in the sequence were usually the previous three terms added together, but more obnoxious. Here's my work:

    1.  1,    1,    2    -> 4    (ok)
    2.  1,    2,    4    -> 7    (ok)
    3.  2,    4,    7    -> 13   (ok)
    4.  4,    7,    13   -> 17   (no) sum does not include second value
    5.  7,    13,   17   -> 30   (no) sum does not include first value
    6.  13,   17,   30   -> 60   (ok)
    7.  17,   30,   60   -> 107  (ok)
    8.  30,   60,   107  -> 197  (ok)
    9.  60,   107,  197  -> 257  (no) sum does not include second value
    10. 107,  197,  257  -> 454  (no) sum does not include first value
    11. 197,  257,  454  -> 908  (ok)
    12. 257,  454,  908  -> 1619 (ok)
    13. 454,  908,  1619 -> 2981 (ok)
    14. 908,  1619, 2981 -> 3889 (no) sum does not include second value
    15. 1619, 2981, 3889 -> 6870 (no) sum does not include first value
    

    So for each five terms, the last two would be calculated differently. The modulo's and if-statements in the while loop of the code handle that.

    MD XF

    Posted 2017-07-21T15:00:01.030

    Reputation: 11 605

    Isn't next-seq a PPCG challenge lol – HyperNeutrino – 2017-09-18T23:54:55.500

    1It's a casewise formula. E.g. a(5*k+2) = a(5*k+1) + a(5*k-1) says that if n % 5 == 2 then a(n) = a(n-1) + a(n-3). – Peter Taylor – 2017-09-19T06:56:50.930

    And this code doesn't calculate it correctly. Input 10 should give 197 and gives 137. – Peter Taylor – 2017-09-19T07:00:58.037

    Guessing the formula was a very bad idea... should I edit to correct this or make it a new answer? After all, the order is already ruined... @PeterTaylor what do you think? – NieDzejkob – 2017-09-19T08:45:55.090

    @NieDzejkob, the explanation of what it should do matches up with the formula given in OEIS: the problem is that the code doesn't implement it. MD XF can almost certainly fix it without changing the byte count, although it might be necessary to muck around with whitespace to achieve that. – Peter Taylor – 2017-09-19T09:30:40.307

    1There's also the problem of segfaulting for n > 100 - keep only the last 3 numbers or allocate this array dynamically – NieDzejkob – 2017-09-19T09:38:10.520

    @PeterTaylor Fixed it, now calculates correctly. – MD XF – 2017-09-19T15:19:33.347

    The posted code is not the same as the code in the test link, and moreover it doesn't fix the out-of-bounds array access pointed out by Nie. – Peter Taylor – 2017-09-19T19:32:56.677

    @PeterTaylor Fixed. And after index 37, int won't be large enough to store the values, so it won't work anyway. – MD XF – 2017-09-19T22:47:39.183

    Since now different compilers are considered different languages, you should declare what compiler this uses. Just some formal stuff. – NieDzejkob – 2017-09-23T12:01:39.553

    2

    161. Ruby, 208 bytes, A000315

    size = gets.chomp.to_i
    puts (1..size).to_a.permutation.to_a.permutation(size).to_a.select{|x| x.transpose.all? {|y| y.uniq.size == y.size} and x[0].sort == x[0] and x.transpose[0].sort == x.transpose[0]}.size
    

    Note that this is an extremely slow implementation. I might make a faster one eventually and post it as a side note (so as to not change the bytecount)

    Also, this is my first Ruby program :D

    Try it on Repl.it!

    Next Sequence

    HyperNeutrino

    Posted 2017-07-21T15:00:01.030

    Reputation: 26 575

    2

    162. Julia 0.6, 448 bytes, A000208

    This is the third time that I've implemented A000013 in this challenge.

    function EulerPhi(n)
      x = 0
      for i = 1:n
        if gcd(i,n) == 1
          x = x + 1
        end
      end
      return x
    end
    
    function A000013(n)
      if n <= 1
        return 1
      end
      x = 0
      for d = 1:n
        if n/d == n÷d
          x = x + (EulerPhi(2*d) * 2^(n/d))/(2*n)
        end
      end
      return x
    end
    
    function A000208(n)
      x = 0
      if n <= 1
        x = 1
      elseif n/2 == n÷2
        x = (A000013(2*n) + A000013(n)) / 2
      else
        x = A000013(2*n) / 2
      end
      return Int(x)
    end  
    

    Try it online!

    Next Sequence

    KSmarts

    Posted 2017-07-21T15:00:01.030

    Reputation: 1 830

    doesn't Julia have a mod operator? It's probably %, but I get that using ÷ is fun, too! – Giuseppe – 2017-09-19T15:41:07.600

    2

    164. cQuents, 1000 bytes, A000227

    $0:R_e^$)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
    

    Try it online!

    Next Sequence

    Explanation

    $0           0-indexed
      :          Mode: Sequence - output whole sequence, or nth item for input n
       R    )    Round - closing paren added if absent
        _e^$     e to the power of the current index
                 Spaces for padding
    

    Stephen

    Posted 2017-07-21T15:00:01.030

    Reputation: 12 293

    I really like the next sequence! – Giuseppe – 2017-09-19T17:30:22.617

    2Am I doing something wrong or is the formula for the next sequence completely incorrect? – NieDzejkob – 2017-09-19T17:43:19.817

    2@NieDzejkob I'm getting completely wrong answers too, so I'm guessing there's a mistake in the formula. – KSmarts – 2017-09-19T17:52:51.940

    somebody had better tell David Wilson... – Giuseppe – 2017-09-19T18:04:28.777

    @Giuseppe is there a way to contact users of the OEIS? – NieDzejkob – 2017-09-19T18:18:05.923

    @NieDzejkob yeah but you have to be a user yourself – Giuseppe – 2017-09-19T18:21:33.370

    2

    165. Forth, 114 bytes, A001000

    : C 4 * 5 - s>f fsqrt f>s ;
    : A 1+ dup 2 < IF 1+ ELSE dup dup * swap dup C dup dup * 4 / 1+ -rot * -1 * + + THEN ;
    

    Try it online

    Next Sequence

    This could have been golfed to 106 by moving C into the function A, but that OEIS sequence looked harder for the next person. Or it grew faster, anyway.

    Explanation:

    In the previous answer, people were unsure of the algorithm for this one. It looked difficult, but the OEIS page stated: "This is the same sequence (apart from the initial term) as A071111." So, I used that sequence, then used an IF THEN ELSE to output 2 if the input is 1.

    I added one at the beginning of the function because the sequence has an offset of one. This makes it zero-indexed.

    The algorithm:

    a(n) = n^2 - n*c(n) + floor(c(n)^2/4) + 1, where c(n) = floor(sqrt(4n-5))
    

    The comments on the page for A071111 also state the results for a(100) and a(1000), and mine are the same.

    mbomb007

    Posted 2017-07-21T15:00:01.030

    Reputation: 21 944

    2

    169. Chez Scheme, 84 bytes, A000261

    (define (a n)
    (if (< n 1)
     n 
     (+ (* (+ n 1) (a (- n 1))) (* (- n 2) (a (- n 2))))))
    

    Try it online!

    Next sequence

    Giuseppe

    Posted 2017-07-21T15:00:01.030

    Reputation: 21 077

    1Note that you could hardcode the next sequence since there are 1000 terms. However, might want to wait until everybody gives up... – totallyhuman – 2017-09-21T16:51:29.140

    @icrieverytim I don't think anybody will give up, the next sequence, while it looks intimidating, is relatively straightforward. – Giuseppe – 2017-09-21T17:18:39.657

    I tried the next sequence once and it was not particularly easy. I never got around to finishing because a 3-chain of answers got deleted because of an integer precision issue with a Java-based language. – HyperNeutrino – 2017-09-21T21:17:42.447

    @HyperNeutrino why wasn't that answer just fixed? – NieDzejkob – 2017-09-22T04:45:29.473

    2

    170. Python 3 (PyPy), 204 bytes, A000084

    n=int(input())+1
    a=[0,1,1,2]
    p=[0,1,3,7]
    for m in range(4,n+1):s=sum([d*a[d]for d in range(1,m)if m%d==0]);u=p[m-1]+2*sum([p[k]*a[m-k]for k in range(1,m-1)])+s;a+=[u//m];p+=[s+u]
    print(2*a[n]if n>1else 1)
    

    Try it online!

    Next sequence!

    4 Pythons down, 2 to go. Wait, there's Python 0 but no one used it in the first 150 answers. 3 to go.

    Ported the second Maple program for A000669. Next sequence is Lucas numbers - as easy as Fibonacci, but nicer.

    NieDzejkob

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 630

    2

    172. Python 1, 55 bytes, A000541

    S=0
    for s in range(-~input()):S=S+s*s*s*s*s*s*s
    print S
    

    Try it online!

    Next Sequence: A000055

    Jonathan Frech

    Posted 2017-07-21T15:00:01.030

    Reputation: 6 681

    2

    176. JavaScript (ES6), 184 bytes, A000122

    function A000122(n) {
     if (n === 0) { return 1; }
     squares = [];
     for (i = 0; i <= 32; i++) {
      squares.push(i*i);
     }
     if (~squares.indexOf(n)) {
      return 2;
     } else {
      return 0;
     }
    }
    

    Try it online!

    Next Sequence

    Stephen

    Posted 2017-07-21T15:00:01.030

    Reputation: 12 293

    2

    188. Groovy, 105 bytes, A000321

    def a
    a = { n -> 
    	if (n == 0G) { 1 }
    	else if (n == 1G) { -1 }
    	else {
    		-a(n-1G)-2G*(n-1G)*a(n-2G)
    	}
    }
    

    Try it online!

    Next Sequence

    Stephen

    Posted 2017-07-21T15:00:01.030

    Reputation: 12 293

    Oh c'mon, not this "sequence sans formula" stuff again... – totallyhuman – 2017-09-26T16:21:01.207

    @icrieverytim read der papers – Stephen – 2017-09-26T16:24:37.330

    a) There's so many papers and b) I don't understand half the stuff they have there. :P – totallyhuman – 2017-09-26T16:25:45.143

    Nooo, I was writing a solution in Shakespeare... whatever. – NieDzejkob – 2017-09-26T16:31:21.687

    @icrieverytim There's a mathematica program; perhaps that could be decoded to get a useful formula – pppery – 2017-09-26T20:46:21.963

    1https://rosettacode.org/wiki/Free_polyominoes_enumeration Pick a language, any language, no need for cri – Husnain Raza – 2017-09-27T02:33:23.133

    2

    189. C# (Visual C# Compiler), 1182 bytes, A000105

    Three parts - the function (824 bytes) + comparer class used in function (273 bytes) + imports (85 bytes)

    n=>{var t=new Func<P,P>[]{p=>new P(p.Y,-p.X),p=>new P(-p.X,-p.Y),p=>new P(-p.Y,p.X),p=>new P(-p.X,p.Y),p=>new P(-p.Y,-p.X),p=>new P(p.X,-p.Y),p=>new P(p.Y,p.X)};Func<P[],P[][]>r=l=>new[]{l}.Concat(new int[7].Select((x,i)=>l.Select(p=>t[i](p)).ToArray())).ToArray();Func<int,P[][]>k=null;k=a=>a<2?new[]{new[]{new P(0,0)}}:k(a-1).SelectMany(l=>l.SelectMany(p=>new[]{new P(p.X-1,p.Y),new P(p.X+1,p.Y),new P(p.X,p.Y-1),new P(p.X,p.Y+1)}).Where(p=>!l.Contains(p)).Distinct().Select(p=>r(l.Concat(new[]{p}).ToArray()).Select(o=>o.Select(c=>new P(c.X-o.Select(q=>q.X).Min(),c.Y-o.Select(q=>q.Y).Min())).OrderBy(q=>q.X).ThenBy(q=>q.Y).ToArray()).Aggregate((m,o)=>(m==null||string.Concat(o.Select(x=>$"({x.X},{x.Y})")).CompareTo(string.Concat(m.Select(x=>$"({x.X},{x.Y})")))<0?o:m)))).Distinct(new C()).ToArray();return k(n).Length;}
    
    class C:IEqualityComparer<P[]>{public bool Equals(P[] f,P[] s)=>f==s?1>0:(f==null|s==null)?1<0:f.OrderBy(p=>p.X).ThenBy(p=>p.Y).Zip(s.OrderBy(p=>p.X).ThenBy(p=>p.Y),(a,b)=>a==b).All(x=>x);public int GetHashCode(P[]l)=>l.Aggregate(0,(a,b)=>a.GetHashCode()^b.GetHashCode());}
    
    using System.Collections.Generic;using P=System.Windows.Point;namespace System.Linq{}
    

    Try it online!

    Next sequence

    I accidentaly deleted the extended version after I golfed it.... Also the code has 2 unneeded spaces added because A001180 was not fun.

    Grzegorz Puławski

    Posted 2017-07-21T15:00:01.030

    Reputation: 781

    2

    193. Hodor, 160 bytes, A000326

    HODOR! = HoDoRHoDoR( HODOR? ) {
    	HOdor!!!(HODOR? == 0)
    	HODOR:: 0;
    	HODOR = 1;
    	Hodor! = 2;
    	hodor = 3;
    	HODOR:: HODOR? * (hodor * HODOR? - HODOR ) / Hodor! ;
    }
    

    Try it online!
    Next sequence

    It's a little inefficient, but please don't hold it against Hodor. He is a little slow, but he's a beautiful gentle giant.

    Grzegorz Puławski

    Posted 2017-07-21T15:00:01.030

    Reputation: 781

    2

    202. Oasis, 50 bytes, A000213

    bc+d+$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$111
    

    $s are filler.

    Try it online!

    Next Sequence

    Stephen

    Posted 2017-07-21T15:00:01.030

    Reputation: 12 293

    2dagnabbit, I had a Cubix solution all ready, I just needed one pad byte to get to 53 :( – Giuseppe – 2017-10-02T23:12:15.277

    2

    205. Commata, 109 bytes, A000053

    Due to the fact that the proper name breaks the snippet, it has been changed. The proper name is ,,,

    14 18 23 28 34 42 50 59 66 72 79 86 96 103 110 116 125 137 145 157 168 181 191 207 215 225 231 238 242 ↺•
    

    Try it online!

    Next sequence. (wtf)

    Hello darkness,,, my old friend.

    totallyhuman

    Posted 2017-07-21T15:00:01.030

    Reputation: 15 378

    On all of these graph theory sequences, I understand exactly what is being asked, but only have a very vague idea of how to actually calculate it. It's very frustrating. – KSmarts – 2017-10-03T03:30:08.273

    Extended by Brendan McKay and Gunnar Brinkmann (Gunnar.Brinkmann(AT)ugent.be) using their program "plantri"

    – NieDzejkob – 2017-10-03T05:33:57.153

    The sequence are the first numbers of even rows of this table, which can theoretically be generated with plantri, an (almost) open source program, but I don't know what options to use to do so.

    – NieDzejkob – 2017-10-03T07:27:11.223

    @NieDzejkob, if you want to reimplement the relevant parts see http://users.cecs.anu.edu.au/~bdm/papers/plantri-full.pdf - although that might be overkill. For code golf the answer has to be theoretically correct but not necessarily fast: generating every possible graph on n vertices and filtering would be a valid approach.

    – Peter Taylor – 2017-10-03T10:26:13.823

    @PeterTaylor Given that the sequence is labeled as "hard" and there is no formula, I'm not sure if there is a more efficient (known) method than brute force. – KSmarts – 2017-10-04T19:21:04.207

    1How can you test if a graph is planar given an adjacency matrix of said graph? – Husnain Raza – 2017-10-04T23:00:45.413

    @HusnainRaza from math.se there are a few linear-time algorithms

    – Giuseppe – 2017-10-05T17:34:55.307

    1@HusnainRaza You can implement an algorithm on your own, or you can just use Mathematica. (PlanarGraphQ) – KSmarts – 2017-10-05T19:24:20.547

    would people be ok with me using mathematica http://www.strawpoll.me/14084506

    – Husnain Raza – 2017-10-06T00:04:59.300

    @HusnainRaza it's not against any rules of challenge or meta, go for it. You can add who inspired/helped your answer (like KSmarts) if you want – Grzegorz Puławski – 2017-10-06T08:55:55.867

    1@HusnainRaza SageMath, Magma, etc. have already been used, and I think this is a reasonable sequence to use math software on. Maple has a graph theory package with an IsPlanar test, if you'd prefer. – KSmarts – 2017-10-06T13:37:45.393

    1sorry, way too hard and dont have enough time, can someone take over? – Husnain Raza – 2017-10-08T02:13:38.917

    1f[x_] := Length[GraphData["Triangulated", x]] works up to x=9... – Stephen – 2017-10-09T13:23:41.090

    @Stephen go, go, go, don't give up – NieDzejkob – 2017-10-09T14:11:28.487

    @HusnainRaza I'll work on it this afternoon if there still isn't an answer – KSmarts – 2017-10-09T15:16:07.643

    Bad news. Mathematica's GraphData requires internet access. It also doesn't seem to have all graphs.

    – totallyhuman – 2017-10-09T15:22:56.393

    Progress so far. It seems to conflict with OEIS's definitions though... – HyperNeutrino – 2017-10-09T15:26:53.120

    @HyperNeutrino wtf you made so much progress and you didn't tell us anything ._. – totallyhuman – 2017-10-09T15:28:09.260

    1@icrieverytim ;_; that was one hour's worth of work lol – HyperNeutrino – 2017-10-09T17:11:09.137

    Pls work we only have until tomorrow ;; – Husnain Raza – 2017-10-09T22:14:02.297

    2

    209. APL (Dyalog), 100 bytes, A000075

    {
        dims ← 1 + 2 * ⍵
        table ← ∘.{+/2 3×⍺ ⍵*2}⍨ ⍳dims
        uniq ← ∪ (dims*2)⍴ table
        +/ (××(2*⍵)≥⊢) uniq
    }
    

    using ⎕IO←0.

    Try it online!

    Next sequence

    Uriel

    Posted 2017-07-21T15:00:01.030

    Reputation: 11 708

    Ugh. I was about to test this. I think this is the theme of this challenge.

    – NieDzejkob – 2017-10-10T12:48:22.517

    @NieDzejkob yea, was hit the same way a few times. they should have set some way to reserve spots – Uriel – 2017-10-10T12:49:53.993

    Yeah, I've seen some other [answer-chaining] question do that. – NieDzejkob – 2017-10-10T12:53:55.547

    2

    212. JavaScript (SpiderMonkey), 79 bytes, A000078

    a = n => n < 3 ? 0 : n == 3 ? 1 : a(--n) + a(--n) + a(--n) + a(--n)
    
    // balloon
    

    Try it online!

    Next sequence.

    totallyhuman

    Posted 2017-07-21T15:00:01.030

    Reputation: 15 378

    @Mr.Xcoder he copypasted the codegolf submission from TIO to edit it later. Common practice if you don't want to get ninjad – NieDzejkob – 2017-10-10T13:50:37.310

    Give a guy some time. :P – totallyhuman – 2017-10-10T13:50:58.633

    1I was just looking at the code snippet, and it looks like Groovy has already been used twice. – KSmarts – 2017-10-10T19:05:55.840

    @KSmarts Oops... – totallyhuman – 2017-10-10T19:13:34.083

    2

    213. Befunge-98 (PyFunge), 117 bytes, A000079

    v   v2<
        * \
        \ -  did you know that comments in befunge start and end with nothing?
          1
    >&1\>:|
          >$.@
    

    Try it online!

    Next sequence!

    NieDzejkob

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 630

    Wait, I thought it was one of these selfreferential sequences like "OEIS sequences that contain their own index number" – NieDzejkob – 2017-10-10T13:57:46.493

    lol no meta sequences pls – totallyhuman – 2017-10-10T13:58:30.110

    2

    214. Julia 0.4, 383 bytes, A000117

    Because of sequence relationships, I've implemented A000013 four times now.

    function EulerPhi(n)
      x = 0
      for i = 1:n
        if gcd(i,n) == 1
          x = x + 1
        end
      end
      return x
    end
    
    function A000013(n)
      if n <= 1
        return 1
      end
      x = 0
      for d = 1:n
        if n/d == n÷d
          x = x + (EulerPhi(2*d) * 2^(n/d))/(2*n)
        end
      end
      return x
    end
    
    function A000011(n)
      return (A000013(n) + 2^(n÷2))/2
    end
    
    function A000117(n)
      return A000011(2*n)
    end
    

    Next Sequence

    Try it online!

    KSmarts

    Posted 2017-07-21T15:00:01.030

    Reputation: 1 830

    ...Dammit, all these n-nacci sequences and I can't answer. ;-; 37 minutes left... – totallyhuman – 2017-10-10T14:14:44.657

    @icrieverytim I was well on my way with a Funciton tetranacci when you posted yours. Serves you right. – KSmarts – 2017-10-10T14:19:06.220

    2

    215. MATL, 95 bytes, A000383

    'this is just a random string for padding aagghhhh need at least 80 chars!'xT6Y"i:"t-5:0)sh]GQ)
    

    Try it online!

    Next sequence

    '...'x                 string and delete from stack
    T6Y"                   push 6 ones
    i:"                    iterate user input number of times
       t-5:0)sh            dup, index last 6, sum, horzcat
               ]           end loop
                GQ)        copy user input, increment, index (return)
    

    Giuseppe

    Posted 2017-07-21T15:00:01.030

    Reputation: 21 077

    Sorry @NieDzejkob :( but you couldn't have answered anyway, your hour wasn't up! – Giuseppe – 2017-10-10T14:41:37.777

    Yeah, right. And you ninjad me by 4 minutes anyway. I just didn't notice your answer and then after posting mine, the page reloaded. – NieDzejkob – 2017-10-10T14:44:56.537

    2

    219. Maxima, 127 bytes, A000702

    load("ratpow")$
    p(n):=num_partitions(n);
    q(n):=ratp_dense_coeffs( product(1+x^(2*k-1),k,1,n) ,x)[n];
    a(n):=(p(n+2)+3*q(n+3))/2;
    

    Next Sequence

    Try it online!

    This uses the first formula on the OEIS page, with a built-in for p and the generating function for q. It's basically the same as the Mathematica code.

    KSmarts

    Posted 2017-07-21T15:00:01.030

    Reputation: 1 830

    2

    220. Visual Basic .NET (.NET Core), 107 bytes, A000127

    Function A000172(n As Integer) As Integer
    n += 1
    Return(n^4 - 6*n^3 + 23*n^2 - 18*n + 24) / 24
    End Function
    

    Try it online!

    Next Sequence

    Note that the implementation of VB.NET on TIO does not have BigIntegers (I tried it and it wants a .dll) so I can use 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.

    Stephen

    Posted 2017-07-21T15:00:01.030

    Reputation: 12 293

    1Maple and Mathematica for the next sequence seem to be using a formula not mentioned in the formula section. – NieDzejkob – 2017-10-11T14:52:27.113

    1Why do so many of the sequences' formula sections say G.f. A(x) = Sum_{n>=1} a(n)*x^n = x / Product_{n>=1} (1-x^n)^a(n)? That's a definition of the generating function. It's not helpful. – KSmarts – 2017-10-11T15:00:48.430

    @KSmarts The first equation does nothing but implicitly saying that the first value is zero and introducing the name a, but the second is unique to this sequence. It allows to incrementally compute the series. If you see it many times maybe that is because A000081 appears so often... – Christian Sievers – 2017-10-11T17:38:16.367

    2

    234. Rust, 512 bytes, A000141

    fn a(n: i64) -> i64 {
        let mut ret = 0;
    
        for a in !n..-!n {
            for b in !n..-!n {
                for c in !n..-!n {
                    for d in !n..-!n {
                        for e in !n..-!n {
                            for f in !n..-!n {
                                if a * a + b * b + c * c + d * d + e * e + f * f == n {
                                    ret += 1;
                                }
                            }
                        }
                    }
                }
            }
        }
    
        return ret;
    }
    

    Try it online!

    Next sequence.

    Nice byte count, eh?

    totallyhuman

    Posted 2017-07-21T15:00:01.030

    Reputation: 15 378

    1I know how to code the next sequence, but idk what language to do it in :( – Husnain Raza – 2017-10-23T12:08:50.943

    @HusnainRaza I posted a bruteforce solution with a broken equivalence checker in Squirrel (the embeddability of Lua, typing of Python and the syntax of C) in The Nineteenth Byte, feel free to salvage stuff.

    – NieDzejkob – 2017-10-23T12:31:02.607

    @HusnainRaza I have discovered a truly marvelous demonstration of this proposition that this margin is too narrow to contain. – KSmarts – 2017-10-23T14:14:18.633

    @NieDzejkob But the equivalence checking is the hard part, isn't it? – KSmarts – 2017-10-23T14:17:03.660

    @KSmarts yes, but the point is an easy to use language with the boilerplate serving at least as a good syntax example. – NieDzejkob – 2017-10-23T14:37:07.730

    2

    238. LOLCODE, 429 bytes, A000089

    HAI 1.2
    
    I HAS A INPUT
    GIMMEH INPUT
    INPUT IS NOW A NUMBR
    INPUT R SUM OF INPUT AN 1
    
    I HAS A COUNT ITZ 0
    I HAS A INDEX ITZ 1
    I HAS A TEMP ITZ 0
    
    IM IN YR LOOP
    TEMP R PRODUKT OF INDEX AN INDEX
    TEMP R SUM OF TEMP AN 1
    TEMP R MOD OF TEMP AN INPUT
    
    BOTH SAEM TEMP AN 0
    O RLY?
     YA RLY
      COUNT R SUM OF COUNT AN 1
    OIC
    
    BOTH SAEM INDEX AN INPUT
    O RLY?
     YA RLY
      GTFO
    OIC
    
    INDEX R SUM OF INDEX AN 1
    IM OUTTA YR LOOP
    
    VISIBLE COUNT
    KTHXBYE
    

    Next Sequence

    Try it online!

    This just directly counts the solutions. None of that Legendre symbol nonsense.

    KSmarts

    Posted 2017-07-21T15:00:01.030

    Reputation: 1 830

    2Mathematics is never nonsense. – user202729 – 2017-10-27T15:10:12.670

    @user202729 That code looks like nonsense to me :P – caird coinheringaahing – 2017-10-27T15:10:32.030

    @user202729 I just meant that it seems to over-complicate the problem. Finding the divisors of n and computing the product of a modified Legendre symbol of those divisors is not simpler than just counting, imo. – KSmarts – 2017-10-27T15:32:47.740

    3

    @user202729 Actually...

    – KSmarts – 2017-10-27T16:33:37.063

    2

    240. CHICKEN Scheme, 256 bytes, A000346

    (define (factorial x)
    (cond
    ((< x 2) 1)
    (else (* x (factorial (- x 1))))))
    (define (choose n k)
    (cond
    ((= n 0) 1)(else
    (/ (factorial n) (* (factorial k) (factorial (- n k)))))))
    (define (a000346 n)
    (- (expt 2 (+ 1 (* 2 n))) (choose (+ 1 (* n 2)) (+ n 1))))
    

    Try it online!

    Next sequence

    Giuseppe

    Posted 2017-07-21T15:00:01.030

    Reputation: 21 077

    12*>U2XmX¹>c- crying +1 though lol, despite making mine no longer matter. – Magic Octopus Urn – 2017-10-27T19:18:59.420

    Nice bytecount! – NieDzejkob – 2017-10-27T19:19:05.517

    2I hope I will finish my Trefunge program before someone else finds an easier language for this sequence... – NieDzejkob – 2017-10-27T20:39:49.847

    1@NieDzejkob I found a bunch of easier languages. Go to tio.run, deselect "recreational," and you'll get a whole list of them! – KSmarts – 2017-10-27T23:08:16.330

    1@KSmarts actually, this doesn't work. Haskell still shows up on the list. – NieDzejkob – 2017-10-28T11:12:08.843

    2

    249. PicoLisp, 171 bytes, A000904

    (de a000904 (n)
     (cond
      ((= n 0) 0)
      ((= n 1) 3)
      ((= n 2) 13)
      (T 
      (+ (* (+ n 2) (a000904 (- n 1)))
         (* (+ n 3) (a000904 (- n 2)))
    	 (a000904 (- n 3)))
      )
     )
    )
    

    Try it online!

    next sequence

    Woo! eleventh page!

    Giuseppe

    Posted 2017-07-21T15:00:01.030

    Reputation: 21 077

    1Eleventh? I don't see deleted posts (except my own) and I'm on the 9th... – NieDzejkob – 2017-11-07T19:02:34.497

    @NieDzejkob yeah, the eleventh page if you include all deleted posts. – Giuseppe – 2017-11-07T19:37:54.330

    "Eleventh page" is not as important as "301 answers". If the 301 number is not counting deleted posts, then "all languages available again". I was actually quite disappointed to see that 301 is counting-deleted. – user202729 – 2017-11-08T11:07:12.913

    Yay! No formula! – user202729 – 2017-11-08T11:08:36.623

    @user202729 From Wolfram Mathworld: "The number of self-complementary graphs on n nodes can be obtained from the "graph polynomial" P_n(x) derived form Pólya's enumeration theorem used to enumerate the numbers of simple graphs as P_n(-1)." This is the method that the given Mathematica code uses, because of course Mathematica has a built-in for that. – KSmarts – 2017-11-08T14:28:12.163

    2

    255. Perl 5, 454 bytes, A000098

    sub part {
     my $S;
     if ($_[1]==0) { $S = 1 } elsif ($_[1] < $_[0]) { $S = 0 } else { $S = part($_[0],$_[1]-$_[0])+part($_[0]+1,$_[1]) }
     $S;
    }
    
    sub partsum {
     my @a = (0..$_[0]);
     my $S = 0;
     for my $i (@a) {
      $S += part(1,$i);
     }
     $S;
    }
    
    sub A000097 {
     my @a = (0..$_[0]//2);
     my $S = 0;
     for my $i (@a) {
      $S += partsum($_[0]-2*$i);
     }
     $S;
    }
    
    sub A000098 {
     my @a = (0..$_[0]//3);
     my $S = 0;
     for my $i (@a) {
      $S += A000097($_[0]-3*$i);
     }
     $S;
    }
    

    Next Sequence

    Try it online!

    There's a lot of redundant subroutine calls, so memoization would speed this up a lot.

    KSmarts

    Posted 2017-07-21T15:00:01.030

    Reputation: 1 830

    2

    257. TI-NSpire CX Basic, 144 bytes, A000562

    Define a562(n)=
    Func
    :If n=4 Then
    :  Return 9
    :Else
    :  Return ((27)/(8))*n^(4)-((135)/(4))*n^(3)+((921)/(8))*n^(2)-((539)/(4))*n
    :EndIf
    :EndFunc
    

    Next sequence

    Uses Plouffe's conjecture mentioned in the OEIS entry, note that this is different than TI-Nspire CAS Basic as they are two different models of calculator. Next sequence hopefully is easy.

    This allows the language to be used again before the 300th.

    Husnain Raza

    Posted 2017-07-21T15:00:01.030

    Reputation: 329

    Ugh, the next sequence is gross. – Engineer Toast – 2017-11-20T21:25:35.227

    What if the conjecture is false? Don't you need to prove it? – user202729 – 2017-11-21T09:55:35.447

    The formula a(n) = 27/8n^4 - 135/4n^3 + 921/8n^2 - 539/4n, n>4 does not seem to be labeled as a conjecture. – NieDzejkob – 2017-11-21T10:39:56.937

    @user202729 alternatively, he can verify the results for n up to a thousand. – NieDzejkob – 2017-11-21T10:41:10.807

    2

    263. Visual Basic .NET (.NET Core), 493 bytes, A000091

    It is a multiplicative function. Using a simple prime checking function.

    Now VB .NET was used twice.

    Function IsPrime(p As Integer) As Boolean
     For i = 2 To p - 1
      If p Mod i = 0 Then Return False
     Next
     Return True
    End Function
    
    Function A000091(n As Integer) As Integer
     n += 1
     If n = 1 Then Return 1
     If n Mod 9 = 0 Then Return 0
    
     Dim ans As Integer = 1
     If n Mod 2 = 0 Then ans *= 2
     If n Mod 3 = 0 Then ans *= 2
     While n Mod 2 = 0
      n /= 2
     End While
     For i = 5 To n
     If IsPrime(i) And n Mod i = 0 Then
      If i Mod 3 = 1 Then ans *= 2 Else Return 0
     End If
     Next
     Return ans
    End Function
    

    Try it online!

    Next sequence

    I chose a simple sequence. The smallest unused sequence until now is A000099.

    Colera Su

    Posted 2017-07-21T15:00:01.030

    Reputation: 2 291

    1

    As far as I can tell, A000064 has been used

    – caird coinheringaahing – 2017-11-24T17:21:57.600

    @cairdcoinheringaahing Thanks, fixed. (I sorted the snippet by sequence number and there are no A000064. Did something get wrong?) – Colera Su – 2017-11-24T23:43:02.277

    2

    264. PowerShell, 102 bytes, A000493

    function A000493($n) {return [math]::floor([math]::sin($n))}
    
    # Please, let's get this to 102. Please?
    

    Try it online!

    Next sequence.

    totallyhuman

    Posted 2017-07-21T15:00:01.030

    Reputation: 15 378

    We've already had 64

    – caird coinheringaahing – 2017-11-24T17:20:32.470

    ...I looked at the last answer and it said 64. >.> Padding, hang on. – totallyhuman – 2017-11-24T17:21:14.377

    1

    Actually, there was 95. However, it seems that the MATL submission missed the sequence number in the title, so it isn't shown in the snippet.

    – Colera Su – 2017-11-24T23:46:25.847

    2@totallyhuman well, we got the shit together :P – caird coinheringaahing – 2017-11-25T00:12:34.550

    @cairdcoinheringaahing ugh, the snippet should warn about ill-formatted answers. – NieDzejkob – 2017-11-25T08:28:37.137

    1I just noticed that the bytecount of this answer is a palindrome of the bytecount of the other PowerShell answer :) – NieDzejkob – 2018-01-03T14:55:31.847

    2

    266. UCBLogo, 2572 bytes, A000636

    ; ------ helper function ------ (unrelated to the problem)
    
    ; minimum of two numbers
    to min :x :y
        output ifelse :x<:y [:x] [:y]
    end
    
    ; clone an array
    to clone :arr
        localmake "ans (array (count :arr) (first :arr))
        localmake "offset -1+first :arr
        repeat count :arr [
            setitem (#+:offset) :ans (item (#+:offset) :arr)
        ]
        output :ans
    end
    
    ; ------ coefficient list manipulators ------
    
    ; apply (map binary function)
    to ap :func :x :y
        localmake "ans arz min count :x count :y
        for [i 0 [-1+count :ans]] [ 
            setitem :i :ans (invoke :func item :i :x item :i :y)
        ]
        output :ans
    end
    
    ; zero-indexing zero array : f(x) = 0
    to arz :n 
        localmake "ans (array :n 0)
        repeat :n [setitem #-1 :ans 0]
        output :ans
    end
    
    ; polynomial multiplication
    to convolve :x :y [:newsize (count :x)+(count :y)-1]
        localmake "ans arz :newsize
        for [i 0 [-1+count :x]] [
            for [j 0 [min -1+count :y :newsize-:i-1] 1] [
                setitem :i+:j :ans (item :i+:j :ans) + (item :i :x) * (item :j :y)
            ]
        ]
        output :ans
    end
    
    ; given arr = coefficients of f(x), calculate factor * f(x^n)
    to extend :arr :n [:factor 1]
        localmake "ans arz (-1+count :arr)*:n+1
        repeat count :arr [
            setitem (#-1)*:n :ans (:factor*item #-1 :arr)
        ]
        output :ans
    end
    
    ; calculate :const + :factor * x * p(x)
    to shift :p :factor :const [:size 1+count :p]
        localmake "ans (array :size 0)
        setitem 0 :ans :const    ; 1+...
        repeat :size-1 [
            setitem # :ans (item #-1 :p)*:factor
        ]
        output :ans
    
    end
    
    ; calculate multiplication inverse (1/p(x))
    to inverse :p [:n (count :p)]
        localmake "one arz :n
        setitem 0 :one 1
    
        localmake "p_1 clone :p
        setitem 0 :p_1 (-1+item 0 :p_1) ; p_1(x) = p(x) - 1
    
        localmake "q (array 1 0)
        setitem 0 :q (1/item 0 :p) ; q(x) = 1/p(0) (coefficient of x^0)
    
        repeat :n [
            make "q ap "difference :one (convolve :p_1 :q #)
        ]
    
        output :q
    end
    
    ; ------ define functions ------
    
    ; calculate r(x) first n coefficients
    to r :n
        localmake "ans {1}@0
        repeat :n [
            make "ans (shift (ap "sum ap "sum
                convolve convolve :ans :ans :ans ; r[x]^3
                convolve :ans (extend :ans 2 3)  ; 3*r[x]*r[x^2]
                (extend :ans 3 2)  ; 2 r[x^3]
            ) 1/6 1 #)
        ]
        output :ans
    end
    
    ; calculate R(x) first n coefficients
    to BigR :n
        localmake "rn r :n
        output (extend
            ap "sum
                convolve :rn :rn ; r[x]^2
                extend :rn 2     ; r[x^2]
        1 0.5)  ; /2
    end
    
    ; main function
    to main :n
        localmake "Rx bigR :n+1
        localmake "inv_1_xRx inverse shift :Rx -1 1 ; 1 - x*R[x]
        output item :n+1 (extend (ap "sum
            :inv_1_xRx
            convolve
                (shift :Rx 1 1)   ; 1 + x*R[x]
                (extend :inv_1_xRx 2) ; 1/(1 - x^2 * R[x^2])
        ) 1 0.5)
    end
    

    Try it online! (at Anarchy golf performance checker)

    Paste the code there, and then append print main 10 at the end.

    Although Logo has been used twice, UCBLogo only once and FMSLogo only once. In other word, programming languages that has multiple versions tend to have more advantage in this challenge. Next time it will probably be Elica.


    Next sequence.

    user202729

    Posted 2017-07-21T15:00:01.030

    Reputation: 14 620

    Probably the next answer is "using the recurrence formula in the Mathematica code". I don't like that, if anyone do that please also include formula proof. – user202729 – 2017-11-30T15:19:26.667

    Sorry for "just using the formula"... but I promise I will add mathematical explanation. – user202729 – 2017-11-30T16:00:03.457

    2

    270. Husk, 103 bytes, A000118

    ←→-1+1-1+1-1+1-1+1-1+1-1+1-1+1-1+1-1+1-1+1-1+1-1+1-1+1-1+1-1+1-1+1+*1=⁰0*±⁰≠*8Σu†ΠṖp⁰*<1%4⁰*32Σu†ΠṖp/4⁰
    

    Try it online!

    Next Sequence.

    Ignore the madness that precedes the actual code, it’s just fluff to make this 103 bytes.

    How it works

    Husk does not have a “divisors” built-in, so ( has been implemented) this was actually fun to solve.

    • First off, it computes the divisors of N using prime factorization (prime factors, powerset, product of each, deduplicate) and sum them up. Then, it multiplies the result by 8.

    • After that, it computes the sum of N / 4’s divisors, and multiplies it by 32 if N is divisible by 4, or evaluates the whole thing to 0 otherwise.

    • Takes the absolute difference between the above terms.

    • For handling the special case of 0, this just multiplies our result by the sign of N, and adds 1 iff N is 0.

    To put it simply, it calculates (N==0 ? 1 : 0)+sgn(N)(8σ(N)+32σ(N/4)(N%4==0 ? 1:0)).

    Mr. Xcoder

    Posted 2017-07-21T15:00:01.030

    Reputation: 39 774

    I was just about to post a solution in Actually... – NieDzejkob – 2017-11-30T22:00:54.413

    @NieDzejkob Oh sorry for ninja’ing again. At least it was nonetrivial for me, Husk doesn’t have a divisor built-in so... – Mr. Xcoder – 2017-11-30T22:02:17.610

    is divisors in Husk – H.PWiz – 2017-11-30T23:55:54.050

    @H.PWiz It has been added recently right? – Mr. Xcoder – 2017-12-01T06:12:34.303

    @Mr.Xcoder don't be sorry, it's not your fault – NieDzejkob – 2017-12-01T06:23:41.570

    "KEYWORD hard" for the next sequence :( – Giuseppe – 2017-12-01T18:03:46.757

    @Giuseppe I can change it if the community wants me to :-) – Mr. Xcoder – 2017-12-01T18:05:05.520

    @Mr.Xcoder don't, I almost got it – NieDzejkob – 2017-12-02T11:20:21.553

    @NieDzejkob Good luck! :-) (I won’t change it) – Mr. Xcoder – 2017-12-02T11:21:53.170

    Rip challenge :( – Husnain Raza – 2017-12-05T23:24:51.747

    @HusnainRaza If I'm counting right, we still have a day and eight hours left... – NieDzejkob – 2017-12-06T12:33:43.447

    @Husnain There’s still one day and a few hours left. – Mr. Xcoder – 2017-12-06T12:57:34.670

    We can't hardcode, we can't use Mathematica (because it has nothing for this)... It's gonna be really hard... – totallyhuman – 2017-12-07T01:42:49.557

    1@HusnainRaza I said that I will solve it means I will solve it. Don't push me. – user202729 – 2017-12-07T13:46:01.050

    @totallyhuman There is a C program that does it already.

    – KSmarts – 2017-12-07T15:33:22.180

    Anyone else want to do this? ChristianSiever has a better algorithm? – user202729 – 2017-12-07T16:10:06.697

    @user202729 Didn't even start seriously thinking about it – Christian Sievers – 2017-12-07T17:45:46.843

    2

    273. Ohm v2, 123 bytes, A000129

    2¬1+³ⁿ1 2¬-³ⁿ-2¬d/¦                                                                                                        
    

    Try it online! (note the trailing spaces)

    Next Sequence.

    I didn't want to nearly-kill the challenge again, so I chose A000123, which isn't that hard.

    Implements a(n) = ((1+√2)n - (1-√2)n) / (2√2), rounded to the nearest integer (because there are small floating-point inaccuracies).

    Mr. Xcoder

    Posted 2017-07-21T15:00:01.030

    Reputation: 39 774

    I was working on 6502 asm for 272 when this was posted – Tornado547 – 2017-12-07T20:22:20.177

    @Tornado547 I feel ya. It's tough to get an answer in when the sequences are so simple, but you'll have lots of chances! – Giuseppe – 2017-12-07T20:38:20.900

    2

    275. Whispers, 113 bytes, A001021

    > Input
    > 12
    >> 2*1
    >> Output 3
    Rather than add a bunch of spaces,
    I think it'd be better to actually have
    words.
    

    Try it online!

    Next sequence

    How it works

    The parser automatically removes lines that don't match any of the valid regexes, meaning that the code that actually gets executes is

    > Input
    > 12
    >> 2*1
    >> Output 3
    

    Which is executed non-linearly way (as most Whispers programs are), and runs as follows:

    Output ((12) * (Input))
    

    Where * is exponentiation (raising x to the power y)

    caird coinheringaahing

    Posted 2017-07-21T15:00:01.030

    Reputation: 13 702

    What are the rules on using languages newer than the challenge? – KSmarts – 2017-12-07T20:28:27.187

    @KSmarts Just so long as it isn't specifically designed for this challenge (or violate any other standard loophole), it's the same as posting an answer with a newer language on any other question. – caird coinheringaahing – 2017-12-07T21:01:33.620

    What is this sorcery? – NieDzejkob – 2017-12-07T21:29:44.003

    Does this still work if you change acually to actually and remove the duplicate !? – Esolanging Fruit – 2017-12-08T04:17:16.577

    This language reminds me of LLVM IR... – NieDzejkob – 2017-12-09T14:22:27.833

    2

    276. MATLAB, 188 bytes, A000113

    n=input('')+1;
    F=factor(n);
    psi = @(x) x*prod(1+1./unique(F))-(x<2);
    i=sum(F==2);
    j=sum(F==3);
    if i > 5
    i = 3;
    else
    i = floor(i./2);
    end
    if j > 1
    j = 1;
    else
    j = 0;
    end
    psi(n) ./ (2^i*3^j)
    

    Try it online!

    Next Sequence

    As this is a carefully written polyglot with Octave, it will run on TIO.

    Implements the formula with Dedekind's psi function listed in the notes.

    Oddly, there's a dead link for transformation groups on this OEIS wiki page and I'm not entirely sure how to count transformation groups!

    Giuseppe

    Posted 2017-07-21T15:00:01.030

    Reputation: 21 077

    2

    279. Fortran (GFortran), 2852 bytes, A005692

    program beans
    
    integer :: n, first_move, last_move, new_move1, new_move2, turn_count, win_accomplished, cycleq
    
    integer, dimension(270,1000000) :: current_paths, next_paths
    integer :: next_path_count, current_path_count, path_iter, move_iter, cycle_iter
    
    read *,n
    first_move = 2*n+1
    turn_count = 0
    win_accomplished = 0
    
    
    current_paths(1,1)=first_move
    current_path_count=1
    
    
    do while(.true.)
      
      turn_count = turn_count + 1    !current path length
    
      if (first_move == 1) then
        turn_count = 1
        exit
      end if
    
      next_path_count = 1
    
    
      do path_iter=1,current_path_count
        
        cycleq = 0
        last_move = current_paths(turn_count,path_iter)
        !print *,'prince'
        !print *,last_move
        !print *,'prince'
    
      
        if (mod(last_move,2)==1)  then
          if (last_move>1) then
            if (mod(turn_count,2) == 0) then
              cycle
            end if
          end if
        end if
    
        if (last_move==1) then
          if (mod(turn_count,2) == 0) then
            win_accomplished = 1
          end if
    
        else if (mod(last_move,2)==0) then
          new_move1 = last_move/2
    
          do cycle_iter = 1,turn_count
            if (current_paths(cycle_iter,path_iter) == new_move1) then
              cycleq=1
            end if
          end do
    
          if (cycleq == 0) then
            do cycle_iter=1,turn_count
              next_paths(cycle_iter,next_path_count) = current_paths(cycle_iter,path_iter)
            end do 
            next_paths(turn_count+1,next_path_count) = new_move1
            next_path_count = next_path_count + 1
          end if
    
        else 
          new_move1 = 3*last_move + 1
          new_move2 = 3*last_move - 1
    
          cycleq=0
          do cycle_iter = 1,turn_count
            if (current_paths(cycle_iter,path_iter) == new_move1) then
              cycleq=1
            end if
          end do 
    
          if (cycleq == 0) then
            do cycle_iter=1,turn_count
              next_paths(cycle_iter,next_path_count) = current_paths(cycle_iter,path_iter)
            end do 
            next_paths(turn_count+1,next_path_count) = new_move1
            next_path_count = next_path_count + 1
          end if
    
    
          cycleq=0
          do cycle_iter = 1,turn_count
            if (current_paths(cycle_iter,path_iter) == new_move2) then
              cycleq=1
            end if
          end do 
    
          if (cycleq == 0) then
            do cycle_iter=1,turn_count
              next_paths(cycle_iter,next_path_count) = current_paths(cycle_iter,path_iter)
            end do
            next_paths(turn_count+1,next_path_count) = new_move2
            next_path_count = next_path_count + 1
          end if
    
        end if
    
      end do 
    
      if (win_accomplished==1) then
         exit
      end if
    
    
      do path_iter=1,next_path_count-1
        do move_iter=1,turn_count+1
          current_paths(move_iter,path_iter) = next_paths(move_iter,path_iter)
          next_paths(move_iter,path_iter) = 0
        end do
      end do
      
      current_path_count = next_path_count-1
    
    end do
    
    
    print *,turn_count-1
    
    end program beans
    

    Try it online!

    Next Sequence

    I originally wrote a similar program in Python. It properly compiled in Pyon but I wanted to see if I could write it in Fortran first and save Pyon/Python for harder sequences.

    The program relies on the fact that if Jack moves to an odd number then the Giant gains control and will be able to use a never-lose strategy. It starts with a the Giant's fist move [n] then enumerates all the possible games until the first win is found which must be the shortest one since moves are added to each possible game pathway once per iteration of the main loop. If Jack loses in one particular game or if the Giant takes control then that particular game pathway is abandoned which helps save on memory and time.

    The first term in the sequence doesn't make any sense to me since it isn't a win for Jack but I hard coded it in anyway.

    The paper OEIS references helped me understand the sequence. They suggest an algorithm to us on a computer (they calculated the first 525 terms of the sequence by hand) which I didn't use because it seemed a little more difficult to implement but it would probably be faster and much less memory intensive.

    Because of memory limitations, the program won't actually work on all the terms but is fine for terms up to at least 119 (n=109). Note that the two arrays declared at the top have 270x10^6 elements. This allows in the algorithm for 10^6 branches of possible game paths of length 270 moves. None of the first 1000 terms are bigger than 263 so this is still valid for the challenge.

    The next sequence (terms in the continued fraction of Eulers constant) looks pretty hard, but maybe that's just because I don't know how to do it of the top of my head. I promise I didn't engineer my byte-count to pick this, it's just what I ended up with.

    Edit: It seems calculating the terms doesn't seem too hard once you have the actual constant (which is irrational [edit: apparently this is actually not known]). Here are some resources:

    dylnan

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 993

    119 (n=109) Huh? – user202729 – 2017-12-15T06:06:05.193

    NOTE There has already been a deleted answer that hardcodes. Don't do this again if you don't want downvotes. – user202729 – 2017-12-15T06:11:36.567

    @user202729 Haha sorry to disappoint you. I know what a continued fraction is just didn’t know how to calculate it off the top of my head. I agree the next one isn’t that hard – dylnan – 2017-12-15T13:14:18.347

    @user202729 I mean terms of value at least 119, which occurs at n=109 – dylnan – 2017-12-15T13:15:56.203

    R script for the numerator and denominator of the rational approximation of gamma; just need to find a language/library with arbitrary precision rationals/integers to compute the next sequence. – Giuseppe – 2017-12-15T21:19:04.463

    2@Giuseppe it kind of hardcodes the sequence to get a number from which you can compute the sequence. Don't you think that's a little pointless? – NieDzejkob – 2017-12-15T21:22:22.313

    @NieDzejkob yeah, but I don't know that non-hardcoding in a sufficiently precise value for gamma will result in an accurate enough answer. I suppose one of the many different series approximations would probably work but then you may be forced to find a sufficiently powerful approximation for log(n) at some point. – Giuseppe – 2017-12-15T21:30:38.047

    Although the mathworld article does have a formula (25) for gamma that can be computed purely through infinite sums of rationals, but it might not converge very quickly. – Giuseppe – 2017-12-15T21:31:25.283

    1http://www.numberworld.org/y-cruncher/internals/formulas.html – politza – 2017-12-16T08:56:21.113

    Mathematica, Pari/GP, and Magma all have trivial solutions. Of course, they've all been used. – KSmarts – 2017-12-16T21:58:43.520

    2

    283. Ohm v2, 384 bytes, A000126

    ³4+ý³-2-                                                                                                                                                                                                                                                                                                                                                                                        
    

    Try it online!

    Next Sequence. (This one is trivial, the hexagonal numbers!)

    If this were code golf, I could solve this in 6 bytes: 4+ýa‹‹.

    This one was really just Fibonacci(N + 4) - N - 2.

    Mr. Xcoder

    Posted 2017-07-21T15:00:01.030

    Reputation: 39 774

    Please let me do the next one in Hexagony! – NieDzejkob – 2017-12-24T14:41:13.657

    Wait, I still need to wait 45 minutes... I'll try anyway – NieDzejkob – 2017-12-24T14:41:37.290

    2

    287. Scratch 2, 7437 Bytes, A001118

    A001118

    Try it online

    Here is the text version of the full program.

    Below is the portion of the program that represents the code blocks in the image. The full text is much longer, dealing with things irrelevant to this challenge.

            "scripts": [[275.8,
                    75.2,
                    [["procDef", "Power %n %n", ["Base", "exponent"], [1, 1], false],
                        ["setVar:to:", "presult", "1"],
                        ["doRepeat",
                            ["getParam", "exponent", "r"],
                            [["setVar:to:", "presult", ["*", ["readVariable", "presult"], ["getParam", "Base", "r"]]]]]]],
                [539.1,
                    73.2,
                    [["procDef", "Binomial %n %n", ["a", "b"], [1, 1], false],
                        ["call", "FactLoop %n", ["getParam", "a", "r"]],
                        ["setVar:to:", "bin", ["readVariable", "result"]],
                        ["call", "FactLoop %n", ["getParam", "b", "r"]],
                        ["setVar:to:", "bin", ["\/", ["readVariable", "bin"], ["readVariable", "result"]]],
                        ["call", "FactLoop %n", ["-", ["getParam", "a", "r"], ["getParam", "b", "r"]]],
                        ["setVar:to:", "bin", ["\/", ["readVariable", "bin"], ["readVariable", "result"]]]]],
                [286.7,
                    244,
                    [["procDef", "FactLoop %n", ["n"], [1], false],
                        ["setVar:to:", "count", ["getParam", "n", "r"]],
                        ["setVar:to:", "result", "1"],
                        ["doUntil",
                            ["<", ["readVariable", "count"], "2"],
                            [["setVar:to:", "result", ["*", ["readVariable", "result"], ["readVariable", "count"]]],
                                ["changeVar:by:", "count", -1]]]]],
                [44,
                    71,
                    [["whenGreenFlag"],
                        ["doAsk", ""],
                        ["setVar:to:", "nseq", ["answer"]],
                        ["setVar:to:", "sum", 0],
                        ["setVar:to:", "i", 0],
                        ["doRepeat",
                            5,
                            [["call", "Power %n %n", -1, ["readVariable", "i"]],
                                ["setVar:to:", "term", ["readVariable", "presult"]],
                                ["call", "Power %n %n", ["-", 5, ["readVariable", "i"]], ["readVariable", "nseq"]],
                                ["setVar:to:", "term", ["*", ["readVariable", "term"], ["readVariable", "presult"]]],
                                ["call", "Binomial %n %n", 5, ["readVariable", "i"]],
                                ["setVar:to:", "term", ["*", ["readVariable", "term"], ["readVariable", "bin"]]],
                                ["changeVar:by:", "sum", ["readVariable", "term"]],
                                ["changeVar:by:", "i", 1]]],
                        ["say:", ["readVariable", "sum"]]]]],
    

    Next Sequence: Inverse Moebius transformation of triangular numbers

    dylnan

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 993

    +1 for using Scratch and for giving us an easy sequence. Solved in Swift 4 :)

    – Mr. Xcoder – 2017-12-25T20:01:10.930

    Scratch is verbose. (depends on how is the number of bytes counted) – user202729 – 2017-12-26T14:02:59.680

    2

    290. Hy, 337 bytes, A000149

    (import decimal)
    (setv ctx (.getcontext decimal))
    (setv ctx.prec 500)
    (setv iterations 2800)
    
    (defn factorial [n]
      (reduce *
        (range 1 (inc n))
        1))
    
    (defn exp [n series-terms]
      (sum
        (list-comp
          (/ (decimal.Decimal (** n k)) (factorial k))
          (k (range series-terms)))))
    
    (defn A000149 [n]
      (int (exp n iterations)))
    

    Next sequence--here's a nice easy one so you can break out the obscure esolangs. ;^)

    We implement the exponential function by taking partial sums of its MacLaurin series: e^n = Sum[k=0..inf] n^k/k!. For values far away from 0, the series converges more slowly, so we need to calculate a lot of terms to get an accurate result. Trial and error showed that 2800 terms was sufficient for n=1000. The decimal module provides arbitrary-precision arithmetic; 500 significant digits gets us up to n=1000 easily.

    DLosc

    Posted 2017-07-21T15:00:01.030

    Reputation: 21 213

    2

    292. Gaia, 132 bytes, A000130

    ọ0D¦1C1=
    ┅f↑¦Σ2÷                                                                                                                    
    

    Try it online!

    Next sequence.

    The next one should not be too hard (there is a näive approach to generate all the integer partitions, and for each partition P check if P is of length 5 and that each element in P is a square :P). I have solved this in Pyth first, then got a much more efficient technique, which I then ported to Gaia.

    How it works?

    ọ0D¦1C1= | Helper function.
    
    ọ        | Compute the incremental differences (deltas).
     0D¦     | For each, calculate the absolute difference to 0 (absolute value).
        1C   | Count the 1's.
          1= | Return 1 if the result is equal to 1, 0 otherwise.
    
    ┅f↑¦Σ2÷  | Main function. Let N be the input.
    
    ┅        | The integers in the range 1 ... N.
     f       | Compute the permutations.
      ↑¦     | For each permutation, apply the above helper function called monadically.
        Σ    | Sum.
         2÷  | Halve and implicitly display the result.
    

    Mr. Xcoder

    Posted 2017-07-21T15:00:01.030

    Reputation: 39 774

    This one has useful and easy to calculate g.f., but note that (1)² and (-1)² are different ways. You can implement FFT if you like. – user202729 – 2017-12-31T13:51:35.613

    2

    298. dc, 1008 bytes, A001460

    # Define a factorial macro f; expects the accumulator in register a and the loop number
    # (> 0) on the stack
    [
     d        # Duplicate the loop number
     la * sa  # Load accumulator, multiply by loop number, store back in accumulator
     1 -      # Decrement loop number
     d 0<f    # Duplicate; if greater than 0, call the macro again
    ] sf
    
    # Define a wrapper macro F; expects the argument on the stack, and can handle 0
    [
     1 sa   # Store 1 in the accumulator register
     d 0<f  # Duplicate argument; if greater than 0, call macro f
     s_     # This leaves a 0 on the stack; store in register _ to get rid of it
     la     # Load accumulator onto stack
    ] sF
    
    # Main program
    ? sn         # Read input and store in register n
    ln 5 * lF x  # Load n, multiply by 5, take the factorial
    ln 2 * lF x  # Load n, multiply by 2, take the factorial
    ln lF x 3 ^  # Load n, take the factorial, raise to the 3rd power
    *            # Multiply the last two results
    /            # Divide the first result by the product
    p            # Print
    

    Try it online!

    Next sequence.

    DLosc

    Posted 2017-07-21T15:00:01.030

    Reputation: 21 213

    The next one seems to be doable in Unefunge... – NieDzejkob – 2018-01-03T15:51:52.547

    The next one is a lot easier if you have a built-ins for finding lowest common multiple and simplifying fractions. The series is the numerator of the simplified fraction Sum(LCM(1...n)/n) / LCM(1...n). – Engineer Toast – 2018-01-03T16:18:11.263

    2

    299. Unefunge-98 (PyFunge), 137 bytes, A001008

    &1+3p01p12p2g3g::/1-:/d*j:0p%0g\0f-8-j$:3g\/:1g*1p\2g\/1g+1p2g*2p1g2g::/1-:/d*j:0p%0g\0f-8-j$:1g\/1p2g\/2p3g1-:3p:/0ab*-3-*j1g.@ unefunge
    

    Try it online!

    Next sequence!

    Due to the way PyFunge handles input, the input to this program has to be followed by at least one newline.

    Explanation

    I'm calculating GCD twice, both times using the Euclidean algorithm, which is a simple one-liner in Python: while b: a, b = b, a % b (the result is left in a). Here is it implemented in Unefunge:

    ::/1-:/d*j:0p%0g\0f-8-j$ Stack: a b
    ::/1-:/d*j               If b is equal to 0, skip to the $ at the end
              :0p            Save b in a temporary variable
                 %           Stack: a%b
                  0g\        Recall b and swap. Stack: b a%b
                     0f-8-j  Jump to the beginning
                           $ Drop b, which is now equal to 0.
    

    In the explanation of the whole program, I'll replace this snippet with a G. The program uses its first 4 bytes as variables, since the programs in Unefunge can easily modify themselves.

    Byte no    Letter   Purpose
        0               A temporary variable used in the GCD algorithm
        1         n     The numerator of the partial sum
        2         d     The denominator of the partial sum
        3         i     The loop counter
    

    This should be enough to understand the whole program.

    &1+3p       i = int(input()) + 1
    01p         n = 0
    12p         d = 1
                The main loop starts here
    2g3gG:      gcd = GCD(d, i) # Stack: gcd, gcd
    3g\/:                       # Stack: gcd, i // gcd, i // gcd
    1g*1p       n *= i // gcd   # Stack: gcd, i // gcd
    \2g\/1g+1p  n += d // gcd   # Stack: i // gcd
    2g*2p       d *= i // gcd   # Stack empty
    1g2gG:      gcd = GCD(n, d) # Stack: gcd, gcd
    1g\/1p      n //= gcd
    2g\/2p      d //= gcd
    3g1-:3p     i -= 1
    :/0ab*-3-*j If i is not 0, loop
    1g.@        print(n)
    

    NieDzejkob

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 630

    1Note that there must be a trailing newline after input. – user202729 – 2018-01-03T16:21:18.457

    I recall Hyper asking about Series parallel numbers on Math.SE, are you sure it hasn't occurred before?

    – Mr. Xcoder – 2018-01-03T16:25:21.177

    @Mr.Xcoder the snippet doesn't complain, and you know it would. An ill-formatted answer is also out of the question. – NieDzejkob – 2018-01-03T16:27:08.857

    @Mr.Xcoder The related sequence A000084 has been done before. And maybe this one came up in a now-deleted answer?

    – KSmarts – 2018-01-03T22:30:26.813

    @KSmarts Issue already solved

    – user202729 – 2018-01-04T00:52:15.290

    2

    300. C# (.NET Core), 2407 bytes, A000137

    using System;
    using System.Numerics;
    
    public class A000137 {
    
     // Expands the polynomial (1 / x^k)
     public static BigInteger[] ExpandReciprocalPowerK(int k, int max) {
      BigInteger[] result = new BigInteger[max + 1];
      for (int i = 0; i <= max; i++) {
       if (i % k == 0)
        result[i] = new BigInteger(1);
       else
        result[i] = new BigInteger(0);
      }
      return result;
     }
    
     // Calculates p1(x) * p2(x)
     public static BigInteger[] PolynomialMultiply(BigInteger[] x, BigInteger[] y, int max) {
      BigInteger[] result = new BigInteger[max + 1];
      for (int i = 0; i <= max; i++) {
       for (int j = 0; j <= max - i; j++) {
        if (result[i + j] == null)
         result[i + j] = new BigInteger(0);
        result[i + j] += x[i] * y[j];
       }
      }
      return result;
     }
    
     // Calculates (p(x))^n
     public static BigInteger[] PolynomialPower(BigInteger[] x, BigInteger n, int max) {
      BigInteger[] result = x;
      if (BigInteger.Compare(n, new BigInteger(0)) == 0) {
       result = new BigInteger[max + 1];
       result[0] = new BigInteger(1);
       for (int i = 1; i <= max; i++)
        result[i] = new BigInteger(0);
      }
      if (BigInteger.Compare(n, new BigInteger(2)) < 0)
       return result;
    
      BigInteger counter = new BigInteger(1);
      while (BigInteger.Compare(counter, n >> 2) <= 0)
       counter <<= 1;
      
      while (BigInteger.Compare(counter, new BigInteger(0)) > 0) {
       result = PolynomialMultiply(result, result, max);
       if (BigInteger.Compare(n & counter, new BigInteger(0)) != 0)
        result = PolynomialMultiply(result, x, max);
       counter >>= 1;
      }
      return result;
     }
     
     public static void Main(string[] args) {
      try {
       // Get Input
       int n = int.Parse(args[0]);
       BigInteger[] x1 = ExpandReciprocalPowerK(1, n);
       for (int i = 2; i <= n; i++) {
        BigInteger coeff = x1[i];
        x1 = PolynomialMultiply(x1, PolynomialPower(ExpandReciprocalPowerK(i, n), coeff, n), n);
       }
    
       BigInteger[] x2 = new BigInteger[n + 1], x3 = new BigInteger[n + 1], x4 = new BigInteger[n + 1];
       x3[0] = x2[0] = new BigInteger(1) - x1[0]; 
       x4[0] = new BigInteger(1);
       for (int i = 1; i <= n; i++)
        x4[i] = x3[i] = x2[i] = x1[i];
       for (int i = 2; i <= n; i++) {
        x3 = PolynomialMultiply(x3, x2, n);
        for (int j = 0; j <= n; j++)
         x4[j] += x3[j];
       }
       BigInteger[] x5 = PolynomialMultiply(x1, x4, n);
    
       Console.WriteLine(x5[n]); // A000137 is not zero-offset
      }
      catch (Exception e) {
       Console.WriteLine(e);
      }
     }
    
    }
    

    Try it online!

    Next sequence: A002407, Cuban primes

    Second .NET Core C# answer in the first 300 (Since TIO shows both .NET Core and Visual C# Compiler so I assume the two to be different).

    Implementation of the algorithm(Mathematica) in the A000137 page in C#, courtesy to Jean-François Alcover (2016).

    I tried to find the pattern, but failed to arrive an algorithm that solves it. Used Maclaurin series to calculate the expansion of 1/(1-p(x)) where p is a polynomial of x.

    Added some lines so that it points to a nice one

    Shieru Asakoto

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 445

    2

    303. APL (Dyalog), 203 bytes, A000135

    {n←1+⍵⋄++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++≢⊃{{(n≥⍵)/⍵},⍵,⍺+0,⍵}/(2÷3)*⍨1+⍳⌊1.5*⍨n}
    

    Try it online!

    using ⎕IO←0. After removing fillers (+, conjugate in Dyalog APL but it doesn't change the result becuase we're dealing real numbers here):

    {n←1+⍵⋄≢⊃{{(n≥⍵)/⍵},⍵,⍺+0,⍵}/(2÷3)*⍨1+⍳⌊1.5*⍨n}
    

    Next sequence

    leo3065

    Posted 2017-07-21T15:00:01.030

    Reputation: 161

    2Welcome to the site, and nice first post! – caird coinheringaahing – 2018-01-07T19:17:27.077

    2

    304. Clojure, 143 bytes, A000203

    (defn sigma
       [num]
       (reduce +
          (filter
             (comp zero?
                (partial rem num))
             (range 1
                (+ 1 num)))))
    

    Try it online!

    Next sequence

    Uriel

    Posted 2017-07-21T15:00:01.030

    Reputation: 11 708

    2

    305. JavaScript (Node.js), 145 bytes, A000143

    p=Math.pow
    a=(n)=>{q=!n/16;
    for(i=1;i<=n;i++){if(!(n%i))q+=p(-1,i)*p(i,3)}return q*16*p(-1,n)}
    //Filing out characters to get to nearest empty ch
    

    Try it online!

    Next sequence

    If you by chance consider comments cheating here's the same code ungolfed with the same length

    a = function(n) {
    	q=!n/16;
    	for (i = 1; i <= n; i++) {
    		if (n%i==0) q += Math.pow(-1, i) * Math.pow(i, 3)
    	}
    	return q * 16 * Math.pow(-1, n)
    }
    

    Try it online!

    IQuick 143

    Posted 2017-07-21T15:00:01.030

    Reputation: 1 229

    Why would anyone consider this cheating? – NieDzejkob – 2018-01-08T13:53:11.233

    @NieDzejkob Because comments simplifies changing the length of the code. I myself don't think it's that important but you never know. – IQuick 143 – 2018-01-08T16:00:59.457

    2

    310. Pyth, 148 bytes, A000699

    L?>b1*tbsm*y-bdydtUb1;*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1yh
    

    Try it here!

    Next Sequence.

    I am going to regret using Pyth that soon. Implements a recursive function y that:

    • Checks if its argument, b, is higher than 1.
    • If that is true, then it returns (b-1) * Σd=1b-1 y(d) * y(b-d).
    • Otherwise, it just returns 1.

    Mr. Xcoder

    Posted 2017-07-21T15:00:01.030

    Reputation: 39 774

    2

    316. Pascal (FPC), 1808 bytes, A000147

    { ''' }
    Type
    	Num = Integer; // may change this to LongInt or big integer.
    Const
    	maxN = 1010; // Why using dynamic array?
    Var
    	ans, i, n, m, n0: Num;
    	a: Array [1..maxN, 1..maxN] of Num;
    Begin
    	read(n0);
    	inc(n0); // because input is 0-indexing.
    	if n0 > maxN then
    	begin
    		writeln('Input too large!');
    		halt;
    	end;
    	{ Let a[i, j] (a[i][j] in other languages. Pascal multidimensional
    	array indexing looks nicer) be the number of rooted tree with
    	(i) nodes, height at most 2 and all rooted subtree with its
    	root being a child of the root has at least (j) nodes. }
    	for m := 1 to n0 do
    		a[1, m] := 1;
    	{ Because if the tree only have a node, there is no rooted subtree.
    	BTW, Sublime Text doesn't support Pascal well. }
    	for n := 2 to n0 do
    	begin
    		a[n, n-1] := 1;
    		for m := n-2 downto 1 do
    			a[n, m] :=
    			// When there is no rooted subtree of size (m).
    			{ (line comment is FP's extension. TP doesn't have this)
    			(TP = Turbo Pascal) }
    			a[n, m+1]
    			{ When there is a subtree of size (m), the remaining
    			part is a tree of order (n-m) and each rooted subtree
    			has at least (m) nodes. }
    			+ a[n-m, m];
    	end;
    	{ From OEIS page: A tree of diameter 5 is formed from two rooted trees 
    	of height 2, with their roots joined. }
    	ans := 0;
    	for i := 1 to (n0-1) div 2 do
    		{ Assume one of the tree has order (i), then the other 
    		has order (n0-i), where (n0) is the input. }
    		ans += (a[i, 1] - 1) * (a[n0-i, 1] - 1);
    		{ -1 because there is exactly one tree of height < 2
    		and order = i. }
    	if n mod 2 = 0 then
    	begin // Assume both of the rooted subtrees has order (n div 2).
    		i := a[n div 2, 1] - 1;
    		ans += i * (i+1) div 2;
    	end;
    	writeln(ans); // ln = line.
    End.
    { ''',
    
    
    
    print(__import__('base64').b64decode(b'Tm90aGluZyBpbnRlcmVzdGluZy4uLiB0aGlzIGlzIG5vdCBQeXRob24u').decode('ascii')) }
    
    

    Try it online!

    Next sequence! Easy, just implement generating function.

    user202729

    Posted 2017-07-21T15:00:01.030

    Reputation: 14 620

    2

    317. Python 3 (Cython), 652 bytes, A001808

    from itertools import zip_longest
    
    def mul(a, b):
    	return list(map(sum, zip_longest(*[[0] * i + [e * f for j, f in enumerate(b)] for i, e in enumerate(a)], fillvalue = 0)))
    
    # a(x) - b(x)
    def sub(a,b):
    	return list(map(lambda v: v[0] - v[1], zip_longest(a, b, fillvalue = 0)))
    
    # a'(x)
    def polyderiv(a):
    	return[i*x for i,x in enumerate(a)][1:]
    
    # (f(x)/g(x))', first n terms
    def fracderiv(f,g):
    	return sub(mul(polyderiv(f),g),mul(f,polyderiv(g))),mul(g,g)
    
    f = [1]
    g = [1,-11,54,-154,275,-297,132,132,-297,275,-154,54,-11,1]
    F = 1
    
    n = int(input())
    for i in range(n):
    	f, g = fracderiv(f, g)
    	f = f[:n]
    	g = g[:n]
    	F*= i + 1
    
    print(f[0] // g[0] // F)
    

    Try it online!

    Next sequence!

    NieDzejkob

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 630

    2

    319. C (8cc), 292 bytes, A001688

    #include <math.h>
    
    unsigned long factorial(unsigned long f) {
        if ( f == 0 ) 
            return 1;
        return(f * factorial(f - 1));
    }
    
    unsigned long long a(int n) {
        return factorial(n) * (pow(n,4) + (6*pow(n,3)) + (17*pow(n,2)) + (20*n) + 9);
    }
    
    int main(void) {
        printf("%d",a(4));
    }
    

    Next sequence

    MD XF

    Posted 2017-07-21T15:00:01.030

    Reputation: 11 605

    2

    320. Java 7, 308 bytes, A000292

    class Main{
      public static void main(String[] args){
        System.out.println(new Main().BinomialCoefficient(new Long(args[0])+2, 3));
      }
    
      static long BinomialCoefficient(long n, long k){
        return n==k || k<1?
            1
          :
            BinomialCoefficient(n-1, k) + BinomialCoefficient(n-1, k-1);
      }
    }
    

    Easy enough; calculates the Binomial Coefficient of n+2 and 3 as stated in the OEIS sequence.

    Try it online.

    Next sequence

    Kevin Cruijssen

    Posted 2017-07-21T15:00:01.030

    Reputation: 67 575

    2

    321. Racket, 249 bytes, A000308

    #lang racket/base
    (define sub-one (λ (n) (+ n -1)))
    (define sub-two (compose sub-one sub-one))
    (define sub-thr (compose sub-one sub-two))
    (define A000308 (λ (n) (if (< n 4) n (* (A000308 (sub-one n)) (A000308 (sub-two n)) (A000308 (sub-thr n))))))
    

    Jonathan Frech

    Posted 2017-07-21T15:00:01.030

    Reputation: 6 681

    2

    323. Common Lisp, 238 bytes, A000150

    (defun catalan (n)
      (if (zerop n) 1 (/ (* 2 (+ n n -1) (catalan (1- n))) (1+ n))))
    (let ((n (read)))
      (if (= n 0) (print 0)
        (if (evenp n)
          (print (/ (catalan n) 2))
          (print (/ (- (catalan n) (catalan (/ (- n 1) 2))) 2)))))
    

    Try it online!

    Next Sequence

    KSmarts

    Posted 2017-07-21T15:00:01.030

    Reputation: 1 830

    2

    324. Pyon, 559 bytes, A000238

    import fractions,itertools
    global fractions,k,R,itertools;# ugh
    R=[0,1]
    p=lambda a:[i*x for i,x in enumerate(a)][1:]
    A=lambda a,b:list(map(sum,itertools.zip_longest(a,b,fillvalue=0)))
    m=lambda p,q,n:[sum((p+k*[0])[i]*(q+k*[0])[k-i]for i in range(k+1))for k in range(len(p+q)-1)][:n]
    for n in range(len(R),int(input())+2):
    	P=[]
    	for k in range(1, n):P=A(P,[fractions.Fraction(x,k)for x in[0if i%k else R[i//k]for i in range(n)]])
    	f=[0,1];F=1
    	for i in range(n):f=A(p(f),m(f,p([x*2for x in P]),n));F*=i+1
    	R+=[f[0].numerator//F]
    print(R[-1]-m(R,R,len(R))[-1])
    

    Try it online!

    Next sequence!

    I initially wrote an answer that calculated A000150 in Befunge, then KSmarts answered, before Christian Sievers noticed that I've made that mistake. I took my code from this answer, added a call to mul to calculate a different sequence, and golfed it all a lot.

    NieDzejkob

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 630

    TIO doesn't seem to like the # ugh – Christian Sievers – 2018-01-27T15:17:01.893

    @ChristianSievers ugh, fixed – NieDzejkob – 2018-01-27T15:18:20.633

    Is that a bug in Pyon? – Christian Sievers – 2018-01-27T15:22:33.673

    @ChristianSievers There are many bugs in Pyon that I don't intend to fix. The language was made in about half an hour and I don't plan to spend more time on it because it's not really worth it. – HyperNeutrino – 2018-01-27T18:06:15.707

    2

    325. Perl 6, 385 bytes, A000559

    my $n = get+3;
    my @s = 0..$n;
    my $result = 0;
    
    for @s -> $k {
      $result = $result + stirling($n,$k)*stirling($k,3);
    }
    
    say $result;
    
    sub stirling ($n, $k) {
      my @a = 0..$k;
      my $s = 0;
      for @a -> $j {
        $s = $s + ((-1)**($k-$j) * binom($k, $j) * $j**$n);
      }
      return $s / ([*] 1..$k);
    }
    
    sub binom ($n, $k) {
      my $l = $n-$k;
      return ([*] 1..$n) / ( ([*] 1..$k)*([*] 1..$l) );
    }
    

    An operator in square brackets is a reduction operator over a list. So [*] 1..$k is $k factorial.

    Try it online!

    Next Sequence

    KSmarts

    Posted 2017-07-21T15:00:01.030

    Reputation: 1 830

    2

    327. tinylisp, 439 bytes, A000205

    (load library)
    
    (def x^2+3*y^2
     (lambda (x y)
      (add2
       (mul2 x x)
       (* y y 3))))
    
    (def _sum-of-squares?
     (lambda (n x y)
      (if (equal? n (x^2+3*y^2 x y))
       1
       (if (less? n (x^2+3*y^2 x y))
        (if x
         (_sum-of-squares? n 0 (inc y))
         0)
        (_sum-of-squares? n (inc x) y)))))
    
    (def sum-of-squares?
     (lambda (n)
      (_sum-of-squares? n 1 0)))
    
    (def A000205
     (lambda (n)
      (length
       (filter sum-of-squares?
        (1to (pow 2 n))))))
    

    Try it online!

    Next sequence!

    This is pretty slow, but it should work for any input, given enough time and memory.

    The main function, A000205, generates all integers from 1 to 2^n; filters the list, keeping numbers of the form x^2+3*y^2; and returns the length of the resulting list.

    There's probably a better way to check whether a number is of the form x^2+3*y^2. Here's the algorithm I used (see the function _sum-of-squares):

    • Start checking at x=1, y=0. At any point, if x^2+3*y^2 == n, stop and return 1 (truthy).
    • If x^2+3*y^2 is less than n, increment x.
    • If x^2+3*y^2 is greater than n, reset x to 0 and increment y.
    • If, when x is 0, x^2+3*y^2 is still greater than n, then there are no x and y that will make the equation work. Return 0 (falsey).

    DLosc

    Posted 2017-07-21T15:00:01.030

    Reputation: 21 213

    2

    328. MY-BASIC, 222 bytes, A000439

    def lin(n):return     n        :enddef
    def sqr(n):return lin(n)*lin(n):enddef
    def cub(n):return sqr(n)*lin(n):enddef
    def hyp(n):return sqr(n)*sqr(n):enddef
    def seq(n):return(hyp(n)+18*cub(n)+83*sqr(n)+114*lin(n))/24:enddef
    

    Jonathan Frech

    Posted 2017-07-21T15:00:01.030

    Reputation: 6 681

    is the first line just to make the bytecount work? :P – HyperNeutrino – 2018-01-29T02:25:37.503

    @HyperNeutrino ... functionally relevant code formatting! – Jonathan Frech – 2018-01-29T13:33:02.090

    2

    329. Yacas, 155 bytes, A000222

    /* compute the series A000222 with yacas */
    f(n) := Sum(k,2,n,Bin(2*n-k,k) * (n-k)! * (-1)^k * Bin(k,2));
    /* only the space between ! and * is necessary */
    

    Put it in a file and load it with Load("a000222"); - alternatively, there is an online demo of yacas here, you can paste the definition, press Shift+Enter, then input something like f(10); followed again by Shift+Enter.

    Next sequence

    I can explain the series and the formula, but there is a big gap between these explanations:

    The crossrefs entry of A000222 says it is a diagonal of A058057.

    The comments of that series describe n*n matrices where the main diagonal from (1,1) to (n,n) and the diagonal below from (2,1) to (n,n-1) have x entries and the remaining entries are 1.

    The permanents of these matrices are polynomials in x. A058057 gives their coefficients. A bit of experimentation shows that A000222 consists of the coefficients of x^2.

    It follows that A000222 gives the number permutations of {1,...,n} that have exactly two positions i that are mapped to i or (if i>1) to i-1.

    That doesn't seem to help efficiently computing the series, I rather feel I have reconstructed the problem to which the permanent is the answer.

    I had exciting ideas how to compute the permanent in the quotient ring Z[x]/(x^3), because doing it in Z[x] is unnecessary work, but there is an easier way.

    The maple code for A058057 starts with a definition that expresses the polynomial as the sum of k from 0 to n of an integer expresssion in n and k times (x-1)^k. I don't know where this comes from, it might be explained in Riordan's book mentioned in the references. This book has come up often, I think I want it!

    Anyway, the coefficient of x^2 of the last term is (-1)^k*binomial(k,2) for k>=2 and 0 otherwise, which leads to the formula used in the program.

    Christian Sievers

    Posted 2017-07-21T15:00:01.030

    Reputation: 6 366

    The expression of the polynomial as a sum is related to the ménage problem. Judging from the permutations that come up, I think it might have to do with the variations that allow for some (in this case, two) couples to sit together.

    – KSmarts – 2018-01-30T15:38:08.753

    @KSmarts Yes, if there is a meeting of the heterosexual binary couples' society with n couples sitting at one side of a long (not round) table where the women sit first at the odd numbered chairs, there are that many ways for the men to sit such that exactly two couples sit together. – Christian Sievers – 2018-01-30T17:15:07.140

    Now I see why the formula is true. I thought it was somehow derived from the permanent, but it can be obtained in exactly this form by simple combinatorical arguments. The fact that it is a polynomial in x-1 already suggests that is might have come from an application of the principle of inclusion and exclusion. – Christian Sievers – 2018-01-31T02:05:39.993

    2

    331. Coconut, 766 bytes, A001854

    # grow all roted trees on n labeled nodes
    def grow(nodes, tree = (), r = ()):
    	used_nodes = tuple(j for j in nodes |> range if any(j in k for k in tree)) or (0,)
    	available_nodes = tuple(j for j in nodes |> range if j not in used_nodes)
    	if not available_nodes: return tree |> sorted |> tuple,
    	for node in used_nodes:
    		for new_node in available_nodes: r += grow(nodes, (tree, ((node, new_node),)) |*> (+))
    	return r |> set |> sorted |> tuple
    
    # calculate a tree's height
    def tree_height(tree):
    	tree, lengths = tree |> list, {0: 0}
    	while tree:
    		for v in tree:
    			if v[0] in lengths: lengths[v[1]] = lengths[v[0]]+1; tree.remove(v)
    	return lengths.values() |> max
    
    # implement A001854
    def A001854(nodes): return (nodes, sum(map(tree_height, grow(nodes)))) |*> (*)
    

    Jonathan Frech

    Posted 2017-07-21T15:00:01.030

    Reputation: 6 681

    Oh and I tried doing it the way that required nth derivative of some crazy function – IQuick 143 – 2018-02-03T19:17:25.653

    1@IQuick143 Brute. Force. – Jonathan Frech – 2018-02-03T19:28:16.510

    @IQuick143 f=\sum_{k>=1}k*(s_k-s_{k-1}) where s_0(x)=x and s_{h+1}(x)=x*exp(x) is not that crazy... – Christian Sievers – 2018-02-03T21:48:12.030

    2

    333. Swift 3, 219 bytes, A000852

    import Foundation
    {typealias N=NumberFormatter;var i=$0+1,k=0;while i>0 {k+=1;let F=N();F.numberStyle=N.Style.spellOut;if "eo".contains("\(F.string(from:NSNumber(value:k))![" ".startIndex])"){i-=1}};print(k)}as(Int)->()
    

    My previous Physica submission was invalid, because it didn't handle numbers like 14000. This is also compatible with Swift 4, and var f= needn't be included in the byte count.

    Try it online!

    Next sequence.

    Mr. Xcoder

    Posted 2017-07-21T15:00:01.030

    Reputation: 39 774

    You seem to have forgotten your chain number (probably 333). – Jonathan Frech – 2018-02-10T18:41:51.453

    @JonathanFrech Whoops sorry fixed. – Mr. Xcoder – 2018-02-10T18:43:15.360

    2

    338. Triangularity, 287 bytes, A000154

    ...........)...........
    ..........1)1..........
    .........)2)7).........
    ........35)228)........
    .......1834)1738.......
    ......2)195866)24......
    .....87832)3549957.....
    ....6)562356672)979....
    ...4156448)186025364...
    ..016)3826961710272)8..
    .4775065603888)2011929.
    826983504W)IEsm........
    

    Try it online!

    Next Sequence

    The previous sequence is erroneous, so hardcoding the terms listed in OEIS should be allowed as far as I am aware.

    Mr. Xcoder

    Posted 2017-07-21T15:00:01.030

    Reputation: 39 774

    2

    340. x86_64 assembly (nasm), 206 bytes, A000209

    extern printf
    section .data
    fmt: db "%d", 10, 0
    section .text
    global f
    f:
        push rdi
        fild qword [rsp]
        fptan
        fstp st0
        fistp qword [rsp]
        pop rsi
        lea rdi, [rel fmt]
        mov rax, 0
        call printf wrt ..plt
        ret
    

    Try it online!

    Next Sequence

    The only reason I'm printing instead of returning the result is that I needed to get a higher byte count.

    To test save the code below in a206.asm and run

    $ nasm -f elf64 a206.asm
    $ gcc a206.o -o a206
    $ ./a206 11
    -226
    

    Test code:

    extern printf
    section .data
    fmt: db "%d", 10, 0
    section .text
    global f
    f:
        push rdi
        fild qword [rsp]
        fptan
        fstp st0
        fistp qword [rsp]
        pop rsi
        lea rdi, [rel fmt]
        mov rax, 0
        call printf wrt ..plt
        ret
    
    extern atoi
    global main
    main:
        mov rdi, [rsi+8]
        call atoi wrt ..plt
    
        mov rdi, rax
        call f
    
        mov rax, 0
        ret
    

    Tyilo

    Posted 2017-07-21T15:00:01.030

    Reputation: 1 372

    1

    89. PowerShell, 201 bytes, A000386

    function f($m){if($m -lt 1){return 1};1..$m|%{$a=[bigint]1}{$a*=$_}{$a}}
    function A000386($n){if($n -le 2){return 0}3..$n|%{$b=[bigint]0}{$b=(f($_-3))*(f($n+$_-3))/(f($n-$_))/(f(2*$_-6))/(f 3)-$b}{$b}}
    

    Online test suite

    Next Sequence

    Dissection

    Pretty straightforward: the sequence has the formula

    $$A(n) = \sum_{j=3}^n (-1)^{n-j} (j-3)! \binom{n+j-3}{n-j,2j-6,3}$$

    obtained via some algebraic manipulation from the description in A058057. There are a couple of tricky bits:

    x..y
    

    produces a range from x to y, but it counts down if y < x, which is not what I want. That's why both functions have special cases.

    x..y|%{foo}{bar}{baz}
    

    is an abbreviated foreach loop. In more familiar pseudocode it might be

    foo
    for $_ = x to y
      bar
    baz
    

    Peter Taylor

    Posted 2017-07-21T15:00:01.030

    Reputation: 41 901

    1

    108. Proton, 32 bytes, A001589

    a => ((4&(**),(**)&4) + *(+))(a)
    

    Try it online!

    Next Sequence

    The shortest working solution would probably be a=>a**4+4**a :P

    HyperNeutrino

    Posted 2017-07-21T15:00:01.030

    Reputation: 26 575

    1

    111. Ceres, 42 bytes, A000442

    !3*@                                      
    

    Try it online!

    Spacing is to get an unused easy sequence. Many trailing spaces...

    Note that this works for very large values because Python and sympy, though it doesn't look like it because of printing...

    Next Sequence

    HyperNeutrino

    Posted 2017-07-21T15:00:01.030

    Reputation: 26 575

    1

    112. Retina, 49 bytes, A000042

    .+
    $*
    $(Let's just add some padding here, yes)?
    1
    

    The extra part at the end is for it to be 0-indexed, to comply with the spec.

    Try it online!

    Next Sequence

    Business Cat

    Posted 2017-07-21T15:00:01.030

    Reputation: 8 927

    That next sequence looks familiar... – NieDzejkob – 2017-08-15T20:15:22.313

    1@NieDzejkob I'm considering making a programming language that finds the number of positive integers less than 2^n in the form Ax^2+By^2 :P I swear this kind of sequence comprises at least 25% of all OEIS :P they should make a keyword for this – HyperNeutrino – 2017-08-15T20:17:37.803

    @HyperNeutrino Index entries for sequences related to populations of quadratic forms, perhaps?

    – Brian J – 2017-08-15T20:22:06.213

    @HyperNeutrino According to their indexing, there are 53 distinct sequences like that.

    – KSmarts – 2017-08-15T20:22:17.410

    @KSmarts ಠ_ಠ yeah that's too many – HyperNeutrino – 2017-08-15T20:25:35.783

    @HyperNeutrino that'd be creating a language for a specific challenge, not sure whether it is allowed. – NieDzejkob – 2017-08-15T20:29:18.980

    @NieDzejkob probably not I wasn't going to anyway :P it's too useless – HyperNeutrino – 2017-08-15T20:30:51.430

    To the next answerer: the next sequence probably requires arbitrary precision numbers because you have to compute 2^n – pppery – 2017-08-15T20:55:35.310

    3waited a day for the OEIS to not be Ax^2+By^2, but it came full circle – Magic Octopus Urn – 2017-08-16T02:06:17.117

    @MagicOctopusUrn More like "full ellipse" – Brian J – 2017-08-16T12:12:33.550

    @MagicOctopusUrn It was either Ax^2 + By^2 or binary bead necklaces... – Business Cat – 2017-08-16T12:47:52.327

    @BusinessCat Don't forget partitions. – KSmarts – 2017-08-16T13:08:38.953

    1

    127. Alice, 58 bytes, A000156

    /o
    \i@/1!&w]!k4Pt&wwh..*.&[?~&].hn6*&#2*?+!K;;[q$KW;e)[k[?
    

    Try it online!

    This uses a dynamic programming approach to compute the number of ways to compute m with k squares for all m <= n+1. Using n+1 instead of n allows me to avoid using a conditional when n=0.

    Next sequence

    Nitrodon

    Posted 2017-07-21T15:00:01.030

    Reputation: 9 181

    1

    129. ExtraC, 482 bytes, A000082

    import math
    
    int isprime(long n)do
    	if(n equals 1) return 0
    	if(n equals 2) return 1
    	if(not(n modulus 2)) return 0
    	long max be sqrt(n)
    	for(long i be 2 AND i less max AND increment i)do
    		if(not(n modulus (2 times i plus 1))) return 0
    	end
    	return 1
    end
    
    long n be readint plus 1
    double r be 1
    for(long p be 1 AND p minus 1 less n AND increment p)do
    	if(not(n modulus p))do
    		if(isprime(p))do
    			r be r times (F(1) divide p plus 1)
    		end
    	end
    end
    print((int)(r times (n times n)))
    

    Try it online!

    Next sequence!

    NieDzejkob

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 630

    1

    131. Bean, 116 bytes, A000090

    00000000: a64d a048 8040 a06a 52a0 6acc a06a 8d53  ¦M H.@ jR jÌ j.S
    00000010: a048 4ca0 6a8c 253a 253a a64d a062 8050   HL j.%:%:¦M b.P
    00000020: 80a0 1f20 803c a64d a05e 8053 a062 4ca0  . . .<¦M ^.S bL 
    00000030: 438e 253c a64d a05f 804c d3a0 4820 5e8d  C.%<¦M _.LÓ H ^.
    00000040: 53d0 80a0 1f20 8046 a53c 205e 264c ccd3  SÐ. . .F¥< ^&LÌÓ
    00000050: a048 2043 8d53 a062 4ccc a05f 8e53 d080   H C.S bLÌ _.SÐ.
    00000060: a01f 2080 3b4c a53a 8e25 3c8b 2581 008e   . .;L¥:.%<.%...
    00000070: 205f ae35                                 _®5
    

    Try it online!

    Next sequence!

    NieDzejkob

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 630

    If I read the haskell for the next sequence right, A000116(n) = A000013(2*n), which is confirmed in comments of A00013. – NieDzejkob – 2017-09-03T08:50:56.590

    1

    132. Java (OpenJDK 9), 903 bytes, A000116

    import java.util.*;
    import java.lang.Math;
    
    public class Main {
        public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            int input = in.nextInt();
            if(input<=0) System.out.print(1);
            else System.out.print(A000013(2*input));
        }
    
        public static int A000013(int n) {  // Uses the formula from the OEIS page
            double result = 0;
            for(int d = 1; d<=n; d++) {
                if(n%d==0) {
                    double t = totient(2*d);
                    double b = Math.pow(2,n/d);
                    result += (t*b)/(2*n);
                }
            }
            int r = (int) result;
            return r;
        }
    
        public static int totient(int n) {  // Follows the definition of Euler's Totient
            int count = 0;
            for(int i = 1; i<n; i++) {
                if(GCD(n,i)==1) count++;
            }
            return count;
        }
    
        public static int GCD(int a, int b) {  // Uses Euclid's Algorithm for GCD
            if(a<b) {
                if(b%a==0) return a;
                return GCD(b%a, a);
            }
            if(a%b==0) return b;
            return GCD(a%b, b);
    
    
        }
    }
    

    Try it online!

    Next Sequence

    I thought I ought to do this one, since it re-implements A000013 and I did that one in the first place.

    KSmarts

    Posted 2017-07-21T15:00:01.030

    Reputation: 1 830

    1

    133. CHICKEN Scheme, 643 bytes, A000903

    (define (g x) 
    (cond ((= x 0) 1) (else x)))
    (define (div4 x)
    (/ (- x (remainder x 4)) 4))
    (define (factorial x)
    (cond ((< x 3) (g x)) 
    (else (* x (factorial (- x 1))))))
    (define (a37223 x)
    (define y (/ (- x (remainder x 2)) 2))
    (* (factorial y) (expt 2 y)))
    (define (a37224 x) 
    (define y (div4 x))
    (cond ((> (remainder x 4) 1) 0) ((= x 1) 1) (else (/ (* 2 (factorial (- (* 2 y) 1))) (factorial (- y 1))))))
    (define (a85 x)
    (cond ((< x 2) 1) (else (+ (a85 (- x 1)) (* (- x 1) (a85 (- x 2)))))))
    (define (a00000000000000000000000000000000000000903 x)
    (cond ((= x 1) 1) (else (/ (+ (factorial x) (+ (a37223 x) (* 2 (+ (a37224 x) (a85 x))))) 8))))
    

    Try it online!

    Next Sequence

    Husnain Raza

    Posted 2017-07-21T15:00:01.030

    Reputation: 329

    It's 627 bytes, not 526, and the Next Sequence link does not point to any of these sequences. I just finished writing a program for A000643... – NieDzejkob – 2017-09-04T08:17:08.767

    1

    137. Squirrel, 701 bytes, A000232

    function A000232(index) {
    local GBTriangle = [[]]
    local numbers = []
    
    for(local i=1; i<index*index*index; i++) numbers.append(i);
    
    // Generate primes with Sieve of Sundaram
    for(local i=1; i<numbers.len(); i++) {
      for(local j=i; i+j+2*i*j<numbers.len(); j++)
        numbers[i+j+2*i*j]=0;
    }
    for(local i=0; i<numbers.len(); i++) {
      if(numbers[i]>0)
        GBTriangle[0].append(2*numbers[i]+1);
    }
    
    // Build the triangle
    for(local i=1; i<=index; i++) {
      GBTriangle.append([])
      for(local a=1; a<GBTriangle[i-1].len(); a++) {
        GBTriangle[i].append( abs( GBTriangle[i-1][a] - GBTriangle[i-1][a-1] ))
      }
    }
    
    for(local i=0; i<GBTriangle[index-1].len(); i++) {
      if(GBTriangle[index-1][i]>2)
        return i;
    }
    
    }
    

    Try it Online!

    Next Sequence

    KSmarts

    Posted 2017-07-21T15:00:01.030

    Reputation: 1 830

    1

    138. Chapel, 689 bytes, A000701

    proc sigma(n: int): int { // A000203
    	var sum: int = 0;
    	for d in 1..n {
    		if n % d == 0 {
    			sum += d;
    		}
    	}
    
    	return sum;
    }
    
    proc sumodd(n: int): int { // A000593
    	var sum: int = 0;
    	for d in 1..n {
    		if (n % d == 0) & (d % 2 == 1) {
    			sum += d;
    		}
    	}
    
    	return sum;
    }
    
    proc part(n: int): int { // A000041
    	if n == 0 { return 1; }
    
    	var sum: int = 0;
    	for k in 0..(n-1) {
    		sum += sigma(n-k) * part(k);
    	}
    
    	return sum / n;
    }
    
    proc helper(n: int): int { // A000700
    	if n == 0 { return 1; }
    
    	var sum: int = 0;
    	for k in 1..n {
    		sum += (if k % 2 == 0 then -1 else 1) * sumodd(k) * helper(n-k);
    	}
    
    	return sum / n;
    }
    
    var n: int;
    n = stdin.read(int);
    
    write((part(n) - helper(n)) / 2);
    

    Should be pretty self-explanatory. I'm surprised such a nice language was available for so long.

    Try it online!

    Next sequence!

    NieDzejkob

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 630

    1

    139. Perl 6, 52 bytes, A000689

    my $n=get();
    $n= 2**$n;
    print substr($n,$n.chars-1);
    

    Try it online!

    Next Sequence

    Stephen

    Posted 2017-07-21T15:00:01.030

    Reputation: 12 293

    The next sequence would be a lot easier if it weren't for the teens. – KSmarts – 2017-09-06T16:38:18.513

    @KSmarts well, there is a Mathematica program, and Mathematica 11 hasn't been used yet... – Stephen – 2017-09-06T16:59:06.450

    1If you'll give me $300, I'll do it in Mathematica. Or give me $240, and I'll do it in Maple. – KSmarts – 2017-09-06T18:43:51.893

    1

    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!

    NieDzejkob

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 630

    1

    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!

    totallyhuman

    Posted 2017-07-21T15:00:01.030

    Reputation: 15 378

    Unfortunately, 29 bytes is unavailable. 31 is the lowest available score – caird coinheringaahing – 2017-09-11T15:07:00.973

    Sike, you thought. :P And yes, I do love my Python 2 for golfing. – totallyhuman – 2017-09-11T15:07:28.287

    1

    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.

    KSmarts

    Posted 2017-07-21T15:00:01.030

    Reputation: 1 830

    Next one is quite the doozy - only 45 terms known, apparently – Stephen – 2017-09-11T17:14:28.653

    @Stephen I only looked at the title before posting this. I guess it's one of those deceptively simple problems. – KSmarts – 2017-09-11T17:31:30.950

    Those usually have a formula or at least a Mathematica program though :P – Stephen – 2017-09-11T17:33:46.723

    What have you done – NieDzejkob – 2017-09-11T17:50:58.303

    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 – 2017-09-11T17:54:10.177

    @Giuseppe when you posted INTERCAL, very nice languages were available: OCaml, Shakespeare Programming Language, Chef, Mornington Crescent, Taxi... also, this problem can be solved with simple algorithm, so if someone posts an answer with the sequence hardcoded, I reserve the right to call him a doody-head in the chat. – NieDzejkob – 2017-09-11T17:59:57.243

    1

    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

    totallyhuman

    Posted 2017-07-21T15:00:01.030

    Reputation: 15 378

    Comments are not for extended discussion; this conversation has been moved to chat.

    – Dennis – 2017-09-24T16:25:02.290

    ...but now I can't comment on my own post. ಠ_ಠ – totallyhuman – 2017-09-24T16:34:10.150

    1

    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

    HyperNeutrino

    Posted 2017-07-21T15:00:01.030

    Reputation: 26 575

    1

    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!

    NieDzejkob

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 630

    1

    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.

    Giuseppe

    Posted 2017-07-21T15:00:01.030

    Reputation: 21 077

    1

    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.

    NieDzejkob

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 630

    1

    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.

    NieDzejkob

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 630

    2Note that hardcoding for less than 1000 digits is completely fine in this case, since this is a finite sequence, not an infinite one. – Stephen – 2017-09-22T12:49:14.553

    1@Stephen unless someone says that this should scrape the subway's website ;) – NieDzejkob – 2017-09-22T12:50:54.903

    @NieDzejkob and OEIS has a broken link... – KSmarts – 2017-09-22T14:29:38.890

    1

    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
    

    Jonathan Frech

    Posted 2017-07-21T15:00:01.030

    Reputation: 6 681

    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 – 2017-09-22T13:29:36.873

    5Gotta love easy tagged sequences without a formula – Stephen – 2017-09-22T13:30:06.817

    Come on! easy but no formula and no program, two out of three links are dead. – NieDzejkob – 2017-09-22T13:51:14.780

    1Good news is that the dead links are archived on web.archive.org – NieDzejkob – 2017-09-22T13:54:00.820

    1

    179. C (clang), 62 bytes, A000933

    f(n){double c=(n>2)*~-~-n*~-~-~-n/3./4;return c+(c-(int)c>0);}
    

    Jonathan Frech

    Posted 2017-07-21T15:00:01.030

    Reputation: 6 681

    1

    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.

    NieDzejkob

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 630

    1

    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);}
    

    Jonathan Frech

    Posted 2017-07-21T15:00:01.030

    Reputation: 6 681

    1Wait wasn't clang used for 180? – Husnain Raza – 2017-09-23T18:01:53.710

    1@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 – 2017-09-23T18:11:39.033

    1

    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

    pppery

    Posted 2017-07-21T15:00:01.030

    Reputation: 3 987

    Think this answer is invalid due to repeated language of last answer :( – Husnain Raza – 2017-09-23T18:04:25.723

    @HusnainRaza this is the second time Common Lisp has been used, that's OK – Stephen – 2017-09-23T18:16:19.437

    @Stephen this is probably not what he meant but this is still valid – NieDzejkob – 2017-09-23T18:17:28.883

    1I 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 – 2017-09-23T19:35:18.313

    1

    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
    

    HyperNeutrino

    Posted 2017-07-21T15:00:01.030

    Reputation: 26 575

    1For 999 this returns 3142, but it should be 3141 – Christian Sievers – 2017-09-23T19:53:55.167

    Where did you get that formula? – NieDzejkob – 2017-09-23T20:19:19.447

    the formula round(3.1416*n-0.790498) works for all n for 2<n<1000 – Husnain Raza – 2017-09-23T22:05:01.247

    @HusnainRaza Thanks for the revised formula edit it doesn't work for 1 -> 6 edit fixed – HyperNeutrino – 2017-09-23T23:49:21.333

    @ChristianSievers Fixed, thanks! – HyperNeutrino – 2017-09-23T23:52:19.840

    just google sheets trend line dabs intensely – Husnain Raza – 2017-09-24T02:39:57.467

    @HusnainRaza why the dabs D: – HyperNeutrino – 2017-09-24T02:53:23.590

    I've failed implementing this sequence, but here is my Jacobi symbol implementation in JavaScript, it might prove useful: j=(a,n)=>{for(var j=1;a;a%=n){while(a%2==0){a/=2;if(n%8==3||n%8==5)j=-j;}t=a;a=n;n=t;if(a%4==3&&n%4==3)j=-j;}if(n!=1)j=0;return j;}; Also, the formula d(a,n)=m^(2n-1)(m*prod_(p_i|m)(p_i^(-1))) * prod_(p_i|m)(p_i^(2*n)-jacobi(b,p_i))d(b,n) doesn't seem to work, see a = 9, for example. (p_i are the odd primes) – NieDzejkob – 2017-09-24T13:41:21.440

    1@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 – 2017-09-24T22:12:51.857

    1

    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

    HyperNeutrino

    Posted 2017-07-21T15:00:01.030

    Reputation: 26 575

    1

    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.

    KSmarts

    Posted 2017-07-21T15:00:01.030

    Reputation: 1 830

    1

    192. Emoji, 326 bytes, A001824

    t110⛽t⛽na4n1an1➡
    

    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.

    NieDzejkob

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 630

    1

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

    KSmarts

    Posted 2017-07-21T15:00:01.030

    Reputation: 1 830

    Crude implementation of the next sequence in Python. It's ridiculously inefficient though. – totallyhuman – 2017-10-02T16:58:33.200

    @icrieverytim That's because you wrote it in Python. – KSmarts – 2017-10-02T17:19:49.143

    1Oi, 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 – 2017-10-02T17:27:29.983

    1

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

    totallyhuman

    Posted 2017-07-21T15:00:01.030

    Reputation: 15 378

    1

    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.

    Giuseppe

    Posted 2017-07-21T15:00:01.030

    Reputation: 21 077

    1

    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!

    NieDzejkob

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 630

    1

    222. Julia 0.4, 110 bytes, A000670

    function A000670(n)
     S = 0
     for k = 0:n
      for j = 0:k
       S = S + (-1)^(k-j)*binomial(k,j)*j^n
      end
     end
    S
    end
    

    Try it online!

    Next sequence

    Implements the formula found on wikipedia to compute a(n) as a sum of binomial coefficients. I suppose I could have implemented this in another language like Racket or something but whatever. Next seq is the Bell numbers, this sequence is the ordered Bell numbers which I find amusing (since they're out of order).

    Giuseppe

    Posted 2017-07-21T15:00:01.030

    Reputation: 21 077

    1

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

    Giuseppe

    Posted 2017-07-21T15:00:01.030

    Reputation: 21 077

    1@NieDzejkob 86 byte answer just so we can all see your opus magnum. – Giuseppe – 2017-10-20T14:56:08.583

    1

    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!

    NieDzejkob

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 630

    1

    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
    

    NieDzejkob

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 630

    1The 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 – 2017-12-24T18:30:18.493

    Unintuitive operand order got me during a last minute change... hang on – NieDzejkob – 2017-12-25T09:26:37.700

    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 – 2017-12-25T10:49:30.793

    @ChristianSievers that's right, I made a mistake when rereading the code, fixed ;) – NieDzejkob – 2017-12-25T11:59:26.347

    1

    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!

    NK1406

    Posted 2017-07-21T15:00:01.030

    Reputation: 739

    1

    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!

    NieDzejkob

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 630

    1

    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.

    Mr. Xcoder

    Posted 2017-07-21T15:00:01.030

    Reputation: 39 774

    1

    289. Pyt, 149 bytes, A000186

    ←Đ000`ŕ4ȘĐ4ȘĐĐĐ5ȘĐĐ5Ș↔⇹5Ș6Ș8Ș3Ș6Ș4Ș⇹3Ș↔⁺3*~4Ș-+~ĐĐ1~⇹^4ȘÅĐ3Ș⇹+⁻ŘΠ⇹↔Đ↔9Ș↔!3Ș⇹3Ș*⇹!÷*3ȘĐ2⇹^⇹!3Ș4Ș⇹÷*⇹Đ0≥*!*+⇹Đ3Ș⇹⁻3Șłŕ⇹ŕ↔Đ↔⇹3Ș⇹3ȘĐ3Ș⇹⁻Đ5Ș4Ș-3Ș⇹łŕ3Ș↔ŕƥĉ
    


    The program is a port of the Mathematica algorithm listed on the OEIS page.

    Most of the work done is managing the stack.

    Try it online!

    Next sequence: floor(e^n)

    mudkip201

    Posted 2017-07-21T15:00:01.030

    Reputation: 833

    Is there an (online) interpreter somewhere we can use to verify this solution? – Giuseppe – 2017-12-29T21:52:04.817

    Unfortunately, no. But I can post the testing file I used to the github page. It'll be pyttesting.py.

    Yes, I know I haven't implemented separate files for holding code - I'll get to that very soon. – mudkip201 – 2017-12-29T22:01:25.487

    Actually, I've now implemented an interpreter that takes a file as a command-line argument – mudkip201 – 2017-12-29T23:00:34.227

    @mudkip201 If you'd like me to add Pyt to TIO, let's meet in http://talk.tryitonline.net.

    – Dennis – 2017-12-31T20:16:28.153

    1

    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

    caird coinheringaahing

    Posted 2017-07-21T15:00:01.030

    Reputation: 13 702

    1

    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:

    an animated GIF

    (bytecount measured according to this meta post)

    NieDzejkob

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 630

    1

    294. Swift 3, 218 bytes, A000431

    import Foundation
    
    infix operator **
    func **(_ base: Int, _ exponent: Int) -> Int{
        return Int(pow(Double(base), Double(exponent)))
    }
    
    func A000431(_ n: Int) -> Int {
    	return ((4 ** Int(n)) - ((2**(n+1)) * n)) / 8
    }
    

    Try it online!

    Next Sequence.

    Note that I have previously used Swift 4 (twice), but this time I used Swift 3. This version thankfully works in both Swift 3 and Swift 4, so this can be tested online.

    Mr. Xcoder

    Posted 2017-07-21T15:00:01.030

    Reputation: 39 774

    1

    296. Pyt, 161 bytes, A000133

    ←ĐĐĐ1⇹1⇹««⇹1⇹«⁻⇹3Ș⁻1⇹«⁺1⇹«*+⇹⁺1⇹«÷                                                                                                                               
    

    All of those spaces at the end are padding.

    Try it online!

    Next Sequence!

    mudkip201

    Posted 2017-07-21T15:00:01.030

    Reputation: 833

    1

    301. Trefunge-98 (PyFunge), 165 bytes, A002407

    "HTRF"4($$&1>::1+::**\::**-3>::*2Pv
            v\$\+#-1_z#;$.@;:R$;^  +2;wOO%#;_v
            >  1^1                  $$<      <
    Yup, Trefunge. Don't worry, I'm not insane.
    

    Try it online!

    Next sequence!

    NieDzejkob

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 630

    1

    302. MOO, 135 bytes, A000165

    return 2 ^ args[1]* $sysobj.sysobj.sysobj.sysobj.sysobj.sysobj.sysobj.sysobj.sysobj.sysobj.sysobj.sysobj.math_utils:factorial(args[1]);
    

    The $sysobj.sysobj.sysobj.sysobj. is pure padding to avoid a duplicate sequence; return 2 ^ args[1]* $math_utils:factorial(args[1]) would do the same thing.

    Next sequence

    pppery

    Posted 2017-07-21T15:00:01.030

    Reputation: 3 987

    Interesting way to do padding... – NieDzejkob – 2018-01-06T14:37:19.400

    Wait, is it this MOO?

    – NieDzejkob – 2018-01-06T14:43:50.547

    this – pppery – 2018-01-06T17:31:02.723

    1

    326. Lua, 205 bytes, A000385

    function Sgm(n)D=0 for d=1,n do if n%d<1then D=D+d end end return D end
    function Sum(a,b,f)S=0 for k=a,b do S=S+f(k)end return S end
    function Seq(n)return Sum(1,n,function(k)return Sgm(k)*Sgm(-~n-k)end)end
    

    Jonathan Frech

    Posted 2017-07-21T15:00:01.030

    Reputation: 6 681

    1

    334. C (tcc), 157 bytes, A000219

    Sigma_2(n){int s=0;for(int d=0;++d<=n;n%d||(s+=d*d));return s;}
    A000219(n){if(!n)return 1;int s=0;for(int k=0;++k<=n;s+=A000219(n-k)*Sigma_2(k));return s/n;}
    

    Jonathan Frech

    Posted 2017-07-21T15:00:01.030

    Reputation: 6 681

    1

    341. Physica, 803 bytes, A000206

    Func Divisors(number: int) – list:
        Return Filter[->divisor: number % divisor == 0; Range[1; number]]
    
    Func GCD(a: int; b: int) – int:
        Return Element[Filter[->number: a % number == b % number == 0; Range[1;Min[{a; b}]]]; 0]
    
    Func EulerPhi(number: int) – int:
        Return Length @ Filter[->a: GCD(a; number) == 1; Range[1; number]]
    
    Func A000013(number: int) – int:
        Return Sum[Map[-> d: (EulerPhi[2 * d] * 2 ^ (number / d)) / (2 * number); Divisors[number]]]
    
    Func A000011(number: int) – int:
        Return (A000013(number) + 2 ^ (number / 2)) / 2
    
    
    Func A000206(number: int) – int:
        If number == 0:
            Return 1
        If number % 2 == 1:
            Return A000011(2*number) / 2
        Else:
            Return (A000011(2*number) + A000011(number) + 4^(number/2 - 1) - 2^(number/2 - 1)) / 2
    

    Next Sequence.

    Demo

    As Physica is not available on TIO yet, here's a GIF:

    Usage GIF

    How it works?

    OEIS states that this is equivalent to the even orbits of binary necklaces of length 2n under Dn x Sn, and so its formula is a(n) = (A000011(2n) + A000011(n) + 4n/2-1 - 2n/2-1) / 2 for even values of n and a(n) = A000011(2n) / 2 if n is odd, with n for non-null values of n, with a(0) = 1. Diving a bit deeper in OEIS, we find that A000011(n)=(A000013(n)+2⌊n / 2⌋) / 2. Using the formula for A000013, the closed-form of A000011 becomes:

         A000011 closed form

    Hence the sequence I implement becomes:

         A000206 – odd n

    When n ≡ 1 (mod 2), else:

    A000206 – even n

    Mr. Xcoder

    Posted 2017-07-21T15:00:01.030

    Reputation: 39 774

    3

    For god's sake we need MathJax back!

    – Mr. Xcoder – 2018-02-26T20:55:00.953

    1

    343. Hodor, 382 bytes, A000164

    HoDoRHoDoR hodor?!? 000164(HODOR? ) {
      $HODOR: HODOR = 0;
      HODOR{} (o=0; o<=HODOR? ; o++) {
        HODOR{} (d=0; d<=o; d++) {
          HODOR{} (r=0; r<=d; r++) {
            if(HODOR... HODOR hodor. h.HODOR. oHODOR!? (o,2)+HODOR... HODOR hodor. h.HODOR. oHODOR!? (d,2)+HODOR... HODOR hodor. h.HODOR. oHODOR!? (r,2)==HODOR? ) {
              HODOR +=1;    }
          }
        }
      }
      HODOR:: HODOR ;
    }
    

    Hodor!

    Hodor.

    KSmarts

    Posted 2017-07-21T15:00:01.030

    Reputation: 1 830

    2This doesn't work in the TIO link for me. It produces h is not defined error – caird coinheringaahing – 2018-02-27T17:43:54.950

    1@cairdcoinheringaahing I had to change it to get a valid byte count, and I guess I missed something. It's fixed now. Um, I mean, Hodor. – KSmarts – 2018-02-27T18:44:34.767

    0

    337. Mathematica 11 (Wolfram Language), 154 bytes, A000159

    A000159[n_] := CoefficientList[ Sum[ 2 * (n+3) / (2 * (n+3)-k) * (2 * (n+3)-k)! / (k! * (2 * (n+3)-2 * k)!) * (n+3-k)! * (x-1)^k , {k,0,n + 3}] ,x] [[4]];
    

    Try it online!

    Next Sequence

    KSmarts

    Posted 2017-07-21T15:00:01.030

    Reputation: 1 830

    1Note that the next sequence is finite as an "erroneous version of A003713" so hard-coding is allowed. Perhaps the next solver could use a more difficult-to-use language? – Giuseppe – 2018-02-22T17:44:32.863

    You should probably add your answer's chain number as well as a link to the sequence you are implementing to comply with the question's rules. – Jonathan Frech – 2018-02-22T18:51:01.917

    2

    @Giuseppe Done, I just used a useless language :P

    – Mr. Xcoder – 2018-02-22T20:21:33.407

    0

    339. ><>, 209 bytes, A000287

    0i:0)?!va{*$"0"-+00.
    :{6401~<vv?(6
    vv?)4:-5<>0n; v<v<v<
    > 1-}r>:?v~n; @+*}@+
    &&    ~  1    :@@:@4
    ~5    ^$-<    !^<^<*
    >>:32,*3!1-@@:}*@:8^
    !v+3*2:@+@@*}<>f2,*v
    ?>@@:}*@@+$:v^:@@+6<
     v@{@{$,@$+4<
    ^>{@{@1+:&:&)
    

    Try it online!

    Next Sequence

    This is the chain's third answer in ><>, meaning it can't be used again until we hit answer #450.

    The next sequence should be pretty easy if you use a language with trig and rounding built in.

    hakr14

    Posted 2017-07-21T15:00:01.030

    Reputation: 1 295

    0

    342. 05AB1E, 164 bytes, A000803

    2‹i0,q}3‹i8,q}0 0 8)I2-FDO4-¸«¦D}θ,                                                                                                                                 
    

    Try it online!

    Next sequence: A000164 - Partition of squares again

    129 spaces padded after the last command.

    Shieru Asakoto

    Posted 2017-07-21T15:00:01.030

    Reputation: 4 445