110
\$\begingroup\$

As of 13/03/2018 16:45 UTC, the winner is answer #345, by Khuldraeseth na'Barya. 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>

\$\endgroup\$
13
  • \$\begingroup\$ Comments are not for extended discussion; this conversation has been moved to chat. \$\endgroup\$
    – Dennis
    Commented Oct 31, 2017 at 2:49
  • \$\begingroup\$ 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? \$\endgroup\$
    – Maya
    Commented Nov 21, 2017 at 15:15
  • 1
    \$\begingroup\$ @Giuseppe No, as you're generating the numbers by doing the maths, rather than just placing them into an array/string \$\endgroup\$ Commented Dec 15, 2017 at 22:14
  • 2
    \$\begingroup\$ @cairdcoinheringaahing In my opinion that's hardcoding the gamma constant. It doesn't work "in theory" for larger numbers. \$\endgroup\$
    – DELETE_ME
    Commented Dec 22, 2017 at 12:44
  • 6
    \$\begingroup\$ Chat room \$\endgroup\$
    – DELETE_ME
    Commented Dec 22, 2017 at 12:45

407 Answers 407

2
\$\begingroup\$

350. Husk, 166 bytes, A000774

*Π¹→ṁ\ḣ
" Explanation
"
" *Π¹→ṁ\ḣ
"    →      1 plus
"     ṁ\     sum of reciprocals of
"       ḣ     the range [1..N]
" *        times
"  Π¹       the factorial of N

Try it online!

Next sequence!

It was surprisingly tricky to get the explanation to come out to the correct length.

\$\endgroup\$
2
\$\begingroup\$

353. Tampio (imperative), 260 bytes, A000197

Pienen Luvun kertoma on
  riippuen siitä, onko se pienempi tai yhtä suuri kuin yksi,
  joko yksi
  tai pieni luku kerrottuna pienen luvun edeltäjän kertomalla.

Luvun edeltäjä on se vähennettynä yhdellä.

Luvun kaksoiskertoma on sen kertoman kertoma.

Next sequence!

Try it online!

Yes, a Finnish programming language, even though I don't speak that language.

Thanks @fergusq for making this awesome language, and writing a detailed introduction.

The code above compiles to the following JavaScript code:

Number.prototype.f_kertoma = function() {
 var pieni_luku = this;
 return ((this<=(1)) ? ((1)) : ((pieni_luku*pieni_luku.f_edeltäjä().f_kertoma())));
};
Number.prototype.f_edeltäjä = function() {
 return (this-(1));
};
Number.prototype.f_kaksoiskertoma = function() {
 return this.f_kertoma().f_kertoma();
};

The first two functions, kertoma (factorial) and edeltäjä (predecessor), are directly taken from fergusq's factorial example in the introduction.

The sequence is defined in the third function: kaksoiskertoma. Since I don't speak Finnish, I can't find a suitable name. Kaksoiskertoma actually means the double factorial (\$n!!=n*(n-2)*(n-4)*\cdots\$), while A000197 is literally applying the factorial function twice.

\$\endgroup\$
2
\$\begingroup\$

356. ArnoldC, 703 bytes, A000244

IT'S SHOWTIME
HEY CHRISTMAS TREE loop
YOU SET US UP @NO PROBLEMO
HEY CHRISTMAS TREE i
YOU SET US UP @I LIED
HEY CHRISTMAS TREE x
YOU SET US UP 1
HEY CHRISTMAS TREE p
YOU SET US UP @NO PROBLEMO
GET YOUR ASS TO MARS p
DO IT NOW
I WANT TO ASK YOU A BUNCH OF QUESTIONS AND I WANT TO HAVE THEM ANSWERED IMMEDIATELY
GET TO THE CHOPPER loop
HERE IS MY INVITATION p
LET OFF SOME STEAM BENNET i
ENOUGH TALK
STICK AROUND loop
 GET TO THE CHOPPER i
 HERE IS MY INVITATION i
 GET UP 1
 ENOUGH TALK
 GET TO THE CHOPPER x
 HERE IS MY INVITATION x
 YOU'RE FIRED 3
 ENOUGH TALK
 GET TO THE CHOPPER loop
 HERE IS MY INVITATION p
 LET OFF SOME STEAM BENNET i
 ENOUGH TALK
CHILL
TALK TO THE HAND x
YOU HAVE BEEN TERMINATED

Try it online!

Next Sequence

\$\endgroup\$
2
\$\begingroup\$

361. Excel (Insider Beta), 272 bytes, A000215

Define name times2 as a LAMBDA function, 224 bytes

times2=LAMBDA(x,y,
 IF(y=0,
    x,
    LET(a,SEQUENCE(LEN(x)),
        b,MID(x,a,1)*2,
        times2(
          CONCAT(IF(INDEX(b,1)>9,1,""),
                 RIGHT(b)+IF(a=LEN(x),0,INT(INDEX(b,a+1)/10))),
          y-1))))

Cell A2, 15 bytes

=times2(1,2^A1)

Cell A3, 33 bytes

=LEFT(A2,LEN(A2)-1)&(RIGHT(A2)+1)

Link to Spreadsheet

Next Sequence

\$\endgroup\$
2
\$\begingroup\$

362. Pyramid Scheme, 324 bytes, A000272

    ^           ^
   / \         /?\
  /set\       ^---^
 ^-----^     /!\ / \
/n\   /#\   ^---/out\
---  ^---  /?\  -----^
    / \   ^---^     /0\
   /   \ /n\ / \    ---
  /line \---/out\
  -------  ^-----
          /^\
         ^---^
        /n\ / \
        ---/ - \
          ^-----^
         /n\   /2\
         ---   ---

Try it online!

Next sequence!

\$\endgroup\$
2
\$\begingroup\$

367. Acc!!, 187 bytes, A000202

N
Count i while _%60/48 {
  _/60*10 + _%60-48
  _*60 + N
}
_/60

_/8 * 13 + (_%8+1) * 8/5

Count d while _/10^d {
  Count i while 9/(_/10^d) * (d+1-i) {
    Write _/10^(d-i)%10 + 48
  }
}

Try it online!

Next sequence!

Explanation

The top and bottom sections are merely code for inputting and outputting a decimal integer, respectively. The line by itself in the middle is what computes the sequence. Observe that i in the OEIS definition is the same as the zero-based index integer-divided by 8, while j (adjusted for zero-indexing) is the remainder of that division, i.e. the index mod 8. After some trial and error, we discover that we can map j to the numbers 1, 3, 4, 6, 8, 9, 11, 12 by a simple linear function.

_                   # The sequence index
 /8                 # int-divided by 8 (i)
   *13              # times 13
      +             # Plus
        _%8         # the index mod 8 (j)
       (   +1)      # plus 1
              *8    # times 8
                /5  # int-divided by 5
\$\endgroup\$
2
+250
\$\begingroup\$

351. Quipu, 178 bytes, A000166

" 0  1  2  3  4"
"--------------"
 \/ 1& 2& 1& 3&
 1& ++ ^^ ++ []
 ++ 0& -- 1& 1&
    []    [] ++
    %%    ** /\
    4&    2&
    ==    []
          --
          1&
          ??

Attempt This Online!

Next sequence!

Based on Aaroneous Miller's factorial answer.

Here is a golfed version.

\$\endgroup\$
2
\$\begingroup\$

370. Swahili, 490 bytes, A000163

shughuli a000163(n) {
    wacha s = []
    kwa i = 0 mpaka n {
        s = s + 1
    }
    kwa i = 2 mpaka n {
        kwa j = 0 mpaka s/i {
            kwa k = i mpaka n {
                s.weka(k, s/k + s/(k-i))
            }
        }
    }
    wacha t = []
    kwa a katika s {
        t = t + 2 * a
    }
    kwa i = 0 mpaka 3 {
        kwa j = 1 mpaka n {
            kwa k = 0 mpaka j {
                t.weka(j, t/j + (t/k) * (s/(j-k)))
            }
        }
    }
    rudisha t
}

Next sequence!

Swahili is a programming language in Swahili.

\$\endgroup\$
2
\$\begingroup\$

371. Factor, 224 bytes, A000490

:: A000364 ( n -- m )
    n [ 1 ] [
        -1 swap ^ neg n iota [| i |
            -1 i ^ i A000364 * 2 n * 2 i * nCk *
        ] map-sum *
    ] if-zero ; flushable
    
: A000490 ( n -- m )
    dup A000364 16 rot ^ * ; inline

Try it online!

Next sequence!

\$\endgroup\$
2
\$\begingroup\$

372. Vyxal, 170 bytes, A000224

ɾ²$%UL

#       | | \ / \ /  _  |
#       \ /  |   X  /_\ |
#        v   |  / \ | | |__
#             
#   Terse, elegant and readable.
#   https://github.com/vyxal/vyxal

Try it Online!

Next Sequence!

My program's only six bytes, so I had to add some advertising :P

ɾ      # 1...n
 ²     # Squared
  $%   # Modulo n
    UL # Count unique
\$\endgroup\$
2
\$\begingroup\$

374. Halfwit, 1091 bytes, A000907

n+:+R*;?>+<*>*<+*>b<>{<?>M<+e?>M<N+R*;**/NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN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codepage. So, I have to include a large amount of NOP Ns as padding. Uses the formula from the OEIS page.

\$\endgroup\$
2
\$\begingroup\$

375. Factor, 231 bytes, A001091

:: A001091 ( m -- n )
    [
        [let
            1 4 :> ( a! b! )
            m [
                b :> c
                b 8 * a - b!
                c a!
            ] times
            a
        ]
    ] 42 [ call ] dip drop ;

Try it online!

Really had to stretch this one to make it long enough from my initial draft of 42 bytes. It's silly, but not overly so, at least until the last line.

Next sequence!

\$\endgroup\$
2
\$\begingroup\$

376. tinylisp, 235 bytes, A000231

(d 2pow (q ((count acc)
 (i count
  (2pow (s count 1) (a acc acc))
   acc))))

(d a000231 (q ((n)
 (a
  (2pow
   (s (2pow n 1) n)
   1)
  (s
   (2pow
    (2pow (s n 1) 1)
    1)
   (2pow
    (s
     (2pow (s n 1) 1)
     n)
    1))))))

Try it online!

Next sequence

We use the formula from the OEIS page, modified to not use multiplication or division:

$$2^{2^{x}-x}+2^{2^{x-1}}-2^{2^{x-1}-x}$$

Then, we implement \$2^n\$ by repeatedly doubling an accumulator.

\$\endgroup\$
2
\$\begingroup\$

378. Factor, 494 bytes, A000258

DEFER: stirling

: (stirling) ( n k -- x )
    [ [ 1 - ] bi@ stirling ]
    [ [ 1 - ] dip stirling ]
    [ nip * + ] 2tri ;

MEMO: stirling ( n k -- x )
    2dup { [ = ] [ nip 1 = ] } 2||
    [ 2drop 1 ] [ (stirling) ] if ;

: stirling2 ( n k -- m )
    2dup { [ = not ] [ nip zero? ] } 2&&
    [ 2drop 0 ] [ stirling ] if ;

: bell ( m -- n )
    [ 1 ] [ dup [1,b] [ stirling ] with map-sum ] if-zero ;

: A000258 ( n -- m )
    dup [0,b] [ [ stirling2 ] keep bell * ] with map-sum ; flushable

Attempt This Online!

Last Factor answer until 450 answers!

Next sequence!

\$\endgroup\$
2
\$\begingroup\$

379. Vyxal, 180 bytes, A000494

∆sṙ
##############
#####    #####
### LOOKS  ###
### LIKE   ###
### I HAVE ###
### TO     ###
### MAKE   ###
### THIS   ###
### 180    ###
### BYTES  ###
##############
   ########

Try it Online!

This is a very simple formula: \$ \large a(n) = \lfloor\sin(n)\rceil \$.

Next sequence!

\$\endgroup\$
2
\$\begingroup\$

383. Wenyan, 1002 bytes, A000241

吾嘗觀「「算經」」之書。方悟「取底」之義。

吾有一術。名之曰「減之取半」。欲行是術。必先得二數。曰「甲」。曰「乙」。乃行是術曰。
 批曰。「「減甲以乙,半之,捨其餘數即得。」」
 減「甲」以「乙」。除其以二。名之曰「丙」。
 施「取底」於「丙」。乃得矣。
是謂「減之取半」也。

吾有一術。名之曰「甲零零零貳肆壹」。欲行是術。必先得一數。曰「甲」。乃行是術曰。
 注曰。「「即OEIS序列A000241也。完全圖之交點之數也,故人嘗尋其通解而不得要領,今解皆臆測也。」」
 吾有二數。曰一。曰零。名之曰「積」。曰「減」。
 為是四遍。
  施「減之取半」於「甲」於「減」。乘「積」以其。昔之「積」者。今其是矣。
  加「減」以一。昔之「減」者。今其是矣。
 云云。
 除「積」以四。乃得矣。
是謂「甲零零零貳肆壹」也。

IDE Next sequence

Uses the conjectured formula

$$\operatorname{A000241}(n)=\frac14\left\lfloor\frac{n}2\right\rfloor\left\lfloor\frac{n-1}2\right\rfloor\left\lfloor\frac{n-2}2\right\rfloor\left\lfloor\frac{n-3}2\right\rfloor$$

because the underlying problem remains open.

Add this snippet to show the first 13 terms (from 0 to 12)

吾有一數。曰零。名之曰「試」。
為是十三遍。
 施「甲零零零貳肆壹」於「試」。書之。
 加「試」以一。昔之「試」者。今其是矣。
云云。
\$\endgroup\$
2
\$\begingroup\$

368. Reason, 1015 bytes, A000187

type expr =
  | Const(int)
  | X
  | Cos(expr)
  | Sin(expr)
  | Add(expr, expr)
  | Mul(expr, expr)
  | Div(expr, expr);

let rec eval_at_0 = (e: expr): int =>
  switch (e) {
  | Const(c) => c
  | X => 0
  | Cos(_) => 1
  | Sin(_) => 0
  | Add(e, f) => eval_at_0(e) + eval_at_0(f)
  | Mul(e, f) => eval_at_0(e) * eval_at_0(f)
  | Div(e, f) => eval_at_0(e) / eval_at_0(f)
  };

let rec deriv = (e: expr): expr =>
  switch (e) {
  | Const(_) => Const(0)
  | X => Const(1)
  | Cos(e) => Mul(Const(-1), Mul(deriv(e), Sin(e)))
  | Sin(e) => Mul(deriv(e), Cos(e))
  | Add(e, f) => Add(deriv(e), deriv(f))
  | Mul(e, f) => Add(Mul(deriv(e), f), Mul(e, deriv(f)))
  | Div(e, f) =>
    Div(
      Add(Mul(deriv(e), f), Mul(Const(-1), Mul(e, deriv(f)))),
      Mul(f, f),
    )
  };

let rec iter = (f, a, n: int) => n > 0 ? f(iter(f, a, n - 1)) : a;

let egf: expr =
  Div(
    Add(Cos(Mul(Const(2), X)), Cos(Mul(Const(4), X))),
    Cos(Mul(Const(5), X)),
  );

let a000187 = (n: int) => eval_at_0(iter(deriv, egf, 2 * n));

Try it online!

Next sequence!

The exponential generating function of the sequence is \$(\cos(2x)+\cos(4x))/\cos(5x)\$. Here I compute the sequence using symbolic differentiation. Very inefficient.

\$\endgroup\$
2
\$\begingroup\$

388. Racket, 192 bytes, A001984

(define (f n)
; AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  (list-ref '(
      7
     23
     71
    311
    479
   1559
   5711
  10559
  18191
  31391
 307271
 366791
 366791
2155919) n))

Try it online!

Since the sequence is erroneous, I hardcoded it.

Next sequence!

\$\endgroup\$
2
\$\begingroup\$

390. Clojure, 191 bytes, A001001

(defn divisors
  [n]
  (filter
    #(zero?
     (rem n %))
    (range 1
      (+ 1 n))))

(defn a001001
  [n]
  (->> n
    (divisors)
    (map #(* % (reduce + (divisors %))))
    (reduce +)))

Try it online!

Next sequence!

\$\endgroup\$
2
\$\begingroup\$

392. Ruby, 212 bytes, A000374

def order(k, n)
  m = 1
  loop {
    return m if k.pow(m, n) == 1
    m += 1
  }
end

def a000374(n)
  (3..n).sum { |d| n % d < 1 && d.odd? ?
    (1..d).count { |x| x.gcd(d) == 1 } / order(2, d) :
    0 } + 1
end

Attempt This Online!

Next sequence!

\$\endgroup\$
2
\$\begingroup\$

396. Desmos, 185 bytes, A000424

A_{000424} \left(  i_{nputVariable}  \right) = \left( i_{nputVariable} + 1 \right)!^{2} \cdot \sum_{m=1}^{i_{nputVariable}+1} \left( \sum_{k=1}^{m} \frac{1}{k} \cdot \frac{1}{m} \right)

Try It On Desmos!

Next Sequence!

\$\endgroup\$
6
  • \$\begingroup\$ How on earth u do the next sequence \$\endgroup\$
    – naffetS
    Commented Sep 2, 2022 at 17:03
  • \$\begingroup\$ @Steffan Lol how am I supposed to know, I didn’t even look at it yet \$\endgroup\$
    – Aiden Chow
    Commented Sep 2, 2022 at 22:23
  • \$\begingroup\$ lol I always try to choose a byte count that has a sequence that isn't impossible \$\endgroup\$
    – naffetS
    Commented Sep 2, 2022 at 22:23
  • \$\begingroup\$ desmos is duplicated \$\endgroup\$ Commented Sep 4, 2022 at 1:48
  • \$\begingroup\$ @ThomasPeng If you read the rules, you will see that: 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). Currently, there are about 400 answers, meaning that Desmos can be used 3 times in total. This is the 3rd answer in Desmos, so it is completely valid to use Desmos (though now Desmos can't be used again until 450 answers). \$\endgroup\$
    – Aiden Chow
    Commented Sep 4, 2022 at 1:50
2
\$\begingroup\$

397. Go, 498 bytes, A000185

import ."math"

func fact(n float64) float64 {
  res := 1.0
  for i := 1.0; i <= n; i++ {
    res *= i
  }
  return res
}

func binomial(n float64, k float64) float64 {
  return fact(n) / (fact(k) * fact(n-k))
}

func A000185(ki int64) int64 {
  s := 0.0
  k := float64(ki)
  n := k + 5.0
  for j := 0.0; j <= k; j++ {
    s += Pow(-1.0, float64(j)) *
         (2.0 * n * fact(k - j) / float64(n + k - j)) * binomial(n - k + j, n - k) * binomial(n + k - j, n - k + j)
  }
  return int64(Round(s))
}

Attempt This Online!

Next sequence!

Since \$A000185(n)\$ = \$A058087(n+5,n)\$, I used the formula by G. C. Greubel on OEIS to calculate A058087+

$$A058087(n,k) = \sum_{j=0}^k (-1)^j\frac{2n(k-j)!}{n+k-j}{{n-k+j}\choose{n-k}}{{n+k-j}\choose{n-k+j}}$$

Therefore:

$$A000185(k) = \sum_{j=0}^k (-1)^j\frac{2(k+5)(k-j)!}{2k+5-j}{{5+j}\choose{5}}{{2k+5-j}\choose{5+j}}$$

\$\endgroup\$
2
\$\begingroup\$

399. PARI/GP, 279 bytes, A000176

D(b,n)=(-1)^(n-1)*if(b%4==1,sum(k=1,(b-1)/2,kronecker(k,b)*(b-4*k)^(2*n-1)),sum(k=0,(b-1)\2,kronecker(b,2*k+1)*(b-2*k-1)^(2*n-1)))
d(a)=my(m,b);[b,m]=core(a,1);if(m>1,if(b>1,1,1/2)*m^7*prod(p=3,m,if(isprime(p)&&!(m%p),(p^4-kronecker(b,p))/p^4,1))*d(b),b==1,2,D(b,2)+3*b^2*D(b,1))

Attempt This Online!

Next sequence!

Using the formula on A000061, or in this paper.

\$\endgroup\$
2
\$\begingroup\$

400. Prolog (SWI), 314 bytes, A000279

Thanks @user for helping me debug my code in the Prolog chat room!

factorial(0,1).
factorial(N,X):-
	A is N-1,
	factorial(A,B),
	X is B*N.

choose(N,R,X):-
	K is N-R,
	factorial(N,A),
	factorial(R,B),
	factorial(K,C),
	X is A/(B*C).

a(_,0,0).
a(N,K,X):-
	A is K-1,
	a(N,A,B),
	choose(N,K,C),
	choose(N,A,D),
	G is N-1,
	choose(G,A,E),
	X is B+3*N*C*D*E.

a000279(N,X):-
	a(N,N,X).

400th answer yay!

Try it online!

Next Sequence!

\$\endgroup\$
1
  • \$\begingroup\$ stop giving us hard sequences lol \$\endgroup\$
    – naffetS
    Commented Sep 4, 2022 at 19:16
2
\$\begingroup\$

402. Crystal, 254 bytes, A000303

def a000303(n)
  # BYTE COUNT HAS TO GET BIGGR
  # BYTE COUNT HAS TO GET BIGGR
  # BYTE COUNT HAS TO GET BIGGR
  (1..n).to_a
        .permutations
        .count { |x|
          x.chunk_while { |a, b| a < b }
           .max_of(&.size) == 2
        }
end

Try it online!

Next sequence!

Ruby has the perfect builtins for this, and Crystal is very similar to Ruby, so it does too.

\$\endgroup\$
2
\$\begingroup\$

405. Cognate, 175 bytes, A000309

Def Fact (
   Let N be the input;
   For Range from 1 to + N 1 (*) 1
);

Def as A000309 (
   Let N be the input;
   * ^ N 2 Fact * 3 N;
   * Fact + 1 * 2 N Fact + 1 N;
   /
);

Attempt This Online!

Next sequence!

\$\endgroup\$
1
\$\begingroup\$

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

\$\endgroup\$
1
\$\begingroup\$

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

\$\endgroup\$
1
\$\begingroup\$

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

\$\endgroup\$
12
  • \$\begingroup\$ That next sequence looks familiar... \$\endgroup\$
    – Maya
    Commented Aug 15, 2017 at 20:15
  • 1
    \$\begingroup\$ @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 \$\endgroup\$
    – hyper-neutrino
    Commented Aug 15, 2017 at 20:17
  • \$\begingroup\$ @HyperNeutrino Index entries for sequences related to populations of quadratic forms, perhaps? \$\endgroup\$
    – Brian J
    Commented Aug 15, 2017 at 20:22
  • \$\begingroup\$ @HyperNeutrino According to their indexing, there are 53 distinct sequences like that. \$\endgroup\$
    – KSmarts
    Commented Aug 15, 2017 at 20:22
  • 3
    \$\begingroup\$ waited a day for the OEIS to not be Ax^2+By^2, but it came full circle \$\endgroup\$ Commented Aug 16, 2017 at 2:06
1
\$\begingroup\$

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

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.