Find the program that prints this integer sequence (Robbers' thread)

20

This is the robbers' thread. The cops' thread goes here.

In the cops thread, the task was to write a program/function that takes a positive (or non-negative) integer and outputs/returns another number (not necessarily integer). The robbers task is to unscramble the code the cops used to produce this output.

The cracked code doesn't have to be identical, as long as it has the same length and any revealed characters are in the correct positions. The language must also be the same (version numbers can be different). The output must of course be identical.

No-ops can be used in robber's solution.

The winner of the robbers thread will be the user who has cracked the most submissions by May 7th 2016. If there's a tie, the user who has cracked submissions with the longest combined code will win.

The submission should be formatted like this:

Language, nn characters (including link to answer), Cop's username

Code:

function a(n)
    if n<2 then
        return n
    else
        return a(n-1) + a(n-2)
    end
end

Output

a(0) returns 0
a(3) returns 2

Optional explanation and comments.

Leaky Nun

Posted 2016-04-09T00:57:38.500

Reputation: 45 011

These rules here are different from the cops thred, where it says: However, any proposed source code that produces the same set of output also counts as valid, as long as it is also found in OEIS. – flawr – 2016-04-09T18:52:41.790

What happens if the examples match multiple OEIS series ? This Just happened with Adnan and me – FliiFe – 2016-04-10T20:06:57.267

@FliiFe Under the current rules, any code which matches the cop's code and outputs an OEIS sequence whose values coincide with the cop's examples is a valid crack. – Mego – 2016-04-11T20:22:33.437

Has this finished? Is there a winner? – Andrew Savinykh – 2016-05-16T02:38:26.580

Answers

7

MATL, 5 bytes, Luis Mendo

H5-*|

This code calculates abs((2-5)*input) which is just a(n)=3*n for positive numbers, which is http://oeis.org/A008585

flawr

Posted 2016-04-09T00:57:38.500

Reputation: 40 560

Well done! My original code was 35B*s :-) – Luis Mendo – 2016-04-09T20:35:39.167

5

Hexagony, 7 bytes, Adnan, A005843

?{2'*!@

or

 ? {
2 ' *
 ! @

Try it online!

Simply doubles the input (and assumes positive input). The code is (for once) simply executed in reading order. The code uses three memory edges A, B, C with the memory pointer starting out as shown:

enter image description here

?    Read integer from STDIN into edge A.
{    Move memory pointer forwards to edge B.
2    Set edge B to 2.
'    Move memory pointers backwards to edge C.
*    Multiply edges A and B and store result in C.
!    Print result to STDOUT.
@    Terminate program.

Martin Ender

Posted 2016-04-09T00:57:38.500

Reputation: 184 808

The exact same with what I had! :) – Leaky Nun – 2016-04-09T10:00:25.677

@KennyLau I think the solution is unique up to swapping the roles of B and C. – Martin Ender – 2016-04-09T10:01:23.067

4

J, 7 bytes, Cᴏɴᴏʀ O'Bʀɪᴇɴ

Code

2+*:@p:

Output

   f =: 2+*:@p:
   f 0
6
   f 2
27

Try it with J.js.

How it works

Sequence A061725 is defined as a(n) := pn² + 2, where pn is the (n + 1)th prime number.

2+*:@p:  Monadic verb. Argument: n

    @    Atop; combine the verbs to the right and to the left, applying one after
         the other.
     p:  Compute the (n+1)th prime number.
  *:     Square it.
2+       Add 2 to the result.

Dennis

Posted 2016-04-09T00:57:38.500

Reputation: 196 637

Nice job! You understand the code more than I did XD – Conor O'Brien – 2016-04-09T14:39:58.847

4

05AB1E, 5 bytes, Adnan, A001788

Læ€OO

Try it online! This uses an alternative definition given on the page. Explanation:

Læ€OO
L     range;      [1..n]
 æ    powerset;   [[], [1], ..., [1..n]]
  €O  mapped sum; [0, 1, ..., T(n)]
    O sum;        [a(n)]

LegionMammal978

Posted 2016-04-09T00:57:38.500

Reputation: 15 731

4

JavaScript, 10 bytes, user81655, A033999

I think I got it. Yeah. This one was really hard. I like the submission because it relies heavily on precedences.


It's the sequence A033999:

a(n) = (-1)^n.

Source

t=>~t.z**t

Explanation

If you split this code according to the JavaScript operator precedences you get:

  1. . (precedence 18) gets evaluated first and t.z will return undefined.
  2. ~ (precedence 15) tries to cast undefined, resulting in 0, and returns -1 after bitwise not.
  3. ** (precedence 14) will return -1 ^ t, where t is odd or even, resulting in -1 or 1.

Demo

console.log(
    (t=>~t.z**t)(0),
    (t=>~t.z**t)(1),
);

Try before buy


I will award a 100 rep bounty on this cool Cop submission.

insertusernamehere

Posted 2016-04-09T00:57:38.500

Reputation: 4 551

1You are correct, congratulations! :) – user81655 – 2016-04-14T08:32:32.797

I consider myself well-versed in javascript, but I have no idea how this works. – Conor O'Brien – 2016-04-14T14:04:44.320

@CᴏɴᴏʀO'Bʀɪᴇɴ I've added an explanation. Hopefully it explains it well enough. – insertusernamehere – 2016-04-14T14:21:04.617

That's why the brute-force didn't find it. I used a transpiler with wrong op precedence >_< – Conor O'Brien – 2016-04-14T14:39:14.733

3

Element, 7 bytes, PhiNotPi, A000042

_'[,1`}

Notes: I was misled by the } for soooooo long. So it also matches [.

Try it online!


How it works:

_'[,1`}
_        main_stack.push(input());
 '       control_stack.push(main_stack.pop());
  [      Object temp = control_stack.pop();
         for(int i=0;i<temp;i++){
   ,         Object a = main_stack.pop(); //is actually zero
             main_stack.push(a.toChars()[0]);
             main_stack.push(a);
    1        main_stack.push(1);
     `       System.out.println(main_stack.pop());
      }  }

Leaky Nun

Posted 2016-04-09T00:57:38.500

Reputation: 45 011

Nice! I was trying this, but I couldn't figure out how to get the , to stop breaking things. – Fund Monica's Lawsuit – 2016-04-09T06:09:42.837

My trick was to do ,$ to produce a 1, which gave me an excuse to put the really confusing , operator in my program. – PhiNotPi – 2016-04-09T06:13:22.257

I was stuck at the } for tooooo long :( – Leaky Nun – 2016-04-09T06:14:06.323

3

05AB1E, 4 bytes, Paul Picard, A001317

Code:

$Fx^

Try it online!

Explanation:

$      # Pushes 1 and input
 F     # Pops x, creates a for-loop in range(0, x)
  x    # Pops x, pushes x and 2x
   ^   # Bitwise XOR on the last two elements
       # Implicit, ends the for-loop
       # Implicit, nothing has printed so the last element is printed automatically

The sequence basically is a binary Sierpinski triangle:

f(0)=      1                    =1
f(1)=     1 1                   =3
f(2)=    1 0 1                  =5
f(3)=   1 1 1 1                 =15
f(4)=  1 0 0 0 1                =17

And translates to the formula a(n) = a(n - 1) XOR (2 × a(n - 1))

Luckily, I remembered this one :)

Adnan

Posted 2016-04-09T00:57:38.500

Reputation: 41 965

1And it is the exact same one, indeed :D – Paul Picard – 2016-04-09T13:06:06.020

3

PHP, 41 bytes, insertusernamehere, A079978

echo/* does n%3=0 */$argv[1]%3<1?1:0    ;

Returns 1 if its argument is a multiple of 3, and 0 otherwise. Not much beyond that.

LegionMammal978

Posted 2016-04-09T00:57:38.500

Reputation: 15 731

Kudos! I had something completely different in mind. :)

– insertusernamehere – 2016-04-09T17:35:56.253

3

Jolf, 3 bytes, Easterly Irk, A001477

axx

Consists of a simple cat (ax) followed by a no-op. Not sure what the cop was going for here.

LegionMammal978

Posted 2016-04-09T00:57:38.500

Reputation: 15 731

That is most definitely not the identity function. It's alert the input. There are actual identity functions :P – Conor O'Brien – 2016-04-10T01:23:27.213

3

MATL, 9 bytes, beaker, A022844

Code (with a whitespace at the end):

3x2xYP*k 

Try it online!

Found the following three matches with a script I wrote:

Found match: A022844
info: "name": "Floor(n*Pi).",

Found match: A073934
info: "name": "Sum of terms in n-th row of triangle in A073932.",

Found match: A120068
info: "name": "Numbers n such that n-th prime + 1 is squarefree.",

I tried to do the first one, which is basically done with YP*k:

3x2x       # Push 3, delete it, push 2 and delete that too
    YP     # Push pi
      *    # Multiply by implicit input
       k   # Floor function

Adnan

Posted 2016-04-09T00:57:38.500

Reputation: 41 965

3

Java, 479 bytes, Daniel M., A000073

Code:

import java.util.*;
public class A{

    public static int i=0;
    public boolean b;

    static A a = new A();

    public static void main(String[] args){
        int input = Integer.parseInt(args[0]);

        LinkedList<Integer> l = new LinkedList<>();
        l.add(1);
        l.add(0);
        l.add(0);

        for(int ix = 0; ix<=input; ix++)if(ix>2){
            l.add(0,l//d
            .get(1)+l.peekFirst()+     l.get(2));
        }

        System.out.println(input<2?0:l.pop()
              +(A.i        +(/*( 5*/ 0 )));
    }
}

If you miss non-revealed characters, they are replaced with spaces.

Vampire

Posted 2016-04-09T00:57:38.500

Reputation: 171

1Very different from the original code, but still, congrats! – Daniel M. – 2016-04-10T02:20:56.273

3

Ruby, 38 bytes, histocrat, A008592

->o{(s="+o++o"*5).sum==03333&&eval(s)}

Could be different from the intended solution as I found this by hand.

xsot

Posted 2016-04-09T00:57:38.500

Reputation: 5 069

Nicely done! Intended solution was similar: "+f+=f"*5. – histocrat – 2016-04-12T13:37:24.963

3

S.I.L.O.S, betseg, A001844

readIO
a=i
a+1
i*2
i*a
i+1
printInt i

Try it online!

Emigna

Posted 2016-04-09T00:57:38.500

Reputation: 50 798

4goddamnit you ninjad me – Destructible Lemon – 2016-10-20T09:22:21.473

2

Jolf, 5 characters, Cᴏɴᴏʀ O'Bʀɪᴇɴ, A033536

Code:

!K!8x

Output:

a(2) = 8
a(10) = 4738245926336

Leaky Nun

Posted 2016-04-09T00:57:38.500

Reputation: 45 011

This was the exact same answer I had. I was about to post it. :( – Fund Monica's Lawsuit – 2016-04-09T01:34:19.710

Neither answer is the original, but they are functionally the same. – Conor O'Brien – 2016-04-09T01:34:38.637

@QPaysTaxes Sorry :( – Leaky Nun – 2016-04-09T01:34:52.830

2

Reng v3.3, 36 bytes, Cᴏɴᴏʀ O'Bʀɪᴇɴ, A005449

iv:#+##->>)2%æ~¡#~
#>:3*1+*^##</div>

Output

a(1) = 2
a(3) = 15

Explanation

I completely ignored the prespecified commands, except the ) because I did not have enough space.

The actually useful commands are here:

iv      >>)2%æ~
 >:3*1+*^

Stretched to a straight line:

i:3*1+*)2%æ~

With explanation:

i:3*1+*)2%æ~ stack
i            [1]      takes input
 :           [1,1]    duplicates
  3          [1,1,3]  pushes 3
   *         [1,3]    multiplies
    1        [1,3,1]  pushes 1
     +       [1,4]    adds
      *      [4]      multiplies
       )     [4]      shifts (does nothing)
        2    [4,2]    pushes 2
         %   [2]      divides
          æ  []       prints
           ~ []       halts

The formula is a(n) = n(3n+1)/2.

Leaky Nun

Posted 2016-04-09T00:57:38.500

Reputation: 45 011

+1 for </div>, an HTML closing tag that somehow appeared in Reng code. – user48538 – 2016-04-17T13:05:38.863

@zyabin101 Wrong place? – Leaky Nun – 2016-04-17T13:06:23.617

Nope. I just like finding hidden secrets in code. :-P – user48538 – 2016-04-17T13:12:22.210

Well this is in the cop's code, so... – Leaky Nun – 2016-04-17T13:13:42.843

2

05AB1E, 3 bytes, Adnan, A000292

LLO

Output

a(9) = 165
a(10) = 220

How it works

LLO Stack
L   [1,2,3,4,5,6,7,8,9]                         range
 L  [1,1,2,1,2,3,1,2,3,4,...,1,2,3,4,5,6,7,8,9] range of range
  O sum all of them

The mathematical equivalent is sum(sum(n)), where sum is summation.

Leaky Nun

Posted 2016-04-09T00:57:38.500

Reputation: 45 011

Nice job, that was the exact same solution :) – Adnan – 2016-04-09T07:52:21.343

2

Python 2, 87 bytes, Sp3000, A083054

n=input()
_=int(3**.5*n)-3*int(n/3**.5)########################################
print _

Not that hard, actually. Just searched for sequences that met the constraints until I found one that could be generated in the given space.

LegionMammal978

Posted 2016-04-09T00:57:38.500

Reputation: 15 731

2

Jolf, 11 bytes, QPaysTaxes, A000005

aσ0xxdxxxxx

Simple enough: alert the σ0 (number of divisors of) x, then put useless stuff at the end.

Try it online! The test suite button's a bit broke, but still shows proper results.

(You could've golfed it down to two bytes! Just σ0 would've done nicely.)

Conor O'Brien

Posted 2016-04-09T00:57:38.500

Reputation: 36 228

1Wow! Le builtins minuscules! +1 – Adnan – 2016-04-09T14:38:53.603

1This is nothing like what I had, but it sure works. Mine was so long because you didn't have any mention of finding divisors in the docs. – Fund Monica's Lawsuit – 2016-04-09T14:40:01.030

@QPaysTaxes I guess I need to update the docs :P But seriously, just Ctrl+F the source code ;) – Conor O'Brien – 2016-04-09T14:40:42.100

I put my original code in my question if you wanna see it. In retrospect, I should have showed different characters :P – Fund Monica's Lawsuit – 2016-04-09T15:35:44.503

2

Jolf, 11 bytes, RikerW, A011551

Code:

c*mf^+91x~P

Explanation:

     +91     # add(9, 1) = 10
    ^   x    # 10 ** input
  mf         # floor function (no-op)
 *       ~P  # multiply by phi
c            # ¯\_(ツ)_/¯

Try it here.

Adnan

Posted 2016-04-09T00:57:38.500

Reputation: 41 965

c is "cast to integer" – Conor O'Brien – 2016-04-14T14:05:05.353

2

JavaScript (ES6), 119 bytes, Cᴏɴᴏʀ O'Bʀɪᴇɴ, A178501

x=>(n="=>[[["|x|"##r(###f#n###;##")|n?Math.pow("#<1##].c####t.##pl##[####nc#"|10,"y([###(###(#]###)"|x-1|``):0|`#h####`

I'm sure the actual code generates a trickier sequence than this, but with just the two outputs, this OEIS sequence is simple and matches them.

Without all the ignored characters, the algorithm is just x=>x?Math.pow(10,x-1):0.

user81655

Posted 2016-04-09T00:57:38.500

Reputation: 10 181

2

05AB1E, 5 bytes, Luis Mendo, A051696

Code:

Ðms!¿

Explanation:

Ð      # Triplicate input.
 m     # Power function, which calculates input ** input.
  s    # Swap two top elements of the stack.
   !   # Calculate the factorial of input.
    ¿  # Compute the greatest common divisor of the top two elements.

So, basically this calculates gcd(n!, nn), which is A051696.

Try it online!.

Adnan

Posted 2016-04-09T00:57:38.500

Reputation: 41 965

2

PHP, 18 bytes, insertusernamehere, A023443

Code:

echo$argv[1]+0+~0;

Output:

a(0) = -1
a(1) = 0

jimmy23013

Posted 2016-04-09T00:57:38.500

Reputation: 34 042

Very nice approach. My source was slightly different: echo$argv[1]+-+!0;. :) – insertusernamehere – 2016-04-10T09:15:02.790

2

Octave (34 bytes) by Stewie Griffin

The sequence is A066911.

@(m)(mod(m,u=1:m  )&isprime(u))*u'

feersum

Posted 2016-04-09T00:57:38.500

Reputation: 29 566

Nice =) For the record, I had u=0:m-1. The same sequence. – Stewie Griffin – 2016-04-10T19:52:53.180

2

PHP, 137 bytes, insertusernamehere, A000959

Code:

for($s=range(1,303);$i<($t=count($s));$s=array_merge($s))for($j=($k=++$i==1?2:$s[$i-1])-1;$j<$t;$j+=$k )unset($s[$j]);echo$s[$argv[1]-1];

Output:

a(3)  =   7
a(7)  =  21
a(23) =  99

jimmy23013

Posted 2016-04-09T00:57:38.500

Reputation: 34 042

Nicely done. Your source is slightly different and you even saved one byte. :)

– insertusernamehere – 2016-04-11T08:13:06.180

2

05AB1E, 10 bytes, George Gibson, A003215

Code:

Ds3*s1+*1+

Explanation:

Computes 3*n*(n+1)+1 which is the oeis sequence A003215.

Emigna

Posted 2016-04-09T00:57:38.500

Reputation: 50 798

1

Element, 10 bytes, PhiNotPi, A097547

2_4:/2@^^`

Try it online!

Output

a(3) = 6561
a(4) = 4294967296

Leaky Nun

Posted 2016-04-09T00:57:38.500

Reputation: 45 011

1

Pyke, 6 bytes, muddyfish, A005563

0QhXts

Yay hacks! The 0Qh and s are no-ops. hXt just computes (n + 1) ^ 2 - 1.

LegionMammal978

Posted 2016-04-09T00:57:38.500

Reputation: 15 731

1

J, 8 bytes, Kenny Lau, A057427

Code:

(-%- )\.

Output:

a(0) = 0
a(1..29) = 1

I don't think this is intended. And I don't know why J had this behavior. But it works.

jimmy23013

Posted 2016-04-09T00:57:38.500

Reputation: 34 042

Gonna add one more restriction xd – Leaky Nun – 2016-04-10T09:45:02.160

1

Pyth, 70 bytes, FliiFe, A070650

Code (with obfuscated version below):

DhbI|qb"#"qb"#"R!1Iqb"#";=^Q6+""s ]%Q27  ;.qlY+Q1Ih+""Z##;.q)=Z+Z1;@YQ
DhbI|qb"#"qb"#"R!1Iqb"#"#####+""s####2###;##lY+Q1Ih+""Z#####)=Z+Z1;@YQ (obfuscated)

This basically does:

=^Q6%Q27

It calculates a(n) = n6 % 27, which is A070650. Explanation:

=^Q6       # Assign Q to Q ** 6
    %Q27   # Compute Q % 27
           # Implicit output

Try it here

Adnan

Posted 2016-04-09T00:57:38.500

Reputation: 41 965

Oops, that's not the one. I updated my answer with another one – FliiFe – 2016-04-10T20:03:26.000

From the rules, this is valid. Congrats ! – FliiFe – 2016-04-10T20:08:15.033

I guess I can tell you the sequence now, It's A007770 (0-indexed) – FliiFe – 2016-04-10T20:31:07.983

@FliiFe Oh, I would never have guessed that :p – Adnan – 2016-04-10T20:32:30.990

Actually, if you know the sequence, it's easily spottable, but if you don't, it becomes really hard – FliiFe – 2016-04-10T20:39:03.913

1

Python, 108, CAD97, A005132

def a(n):
 if n == 0: return 0
 f=a(n-1)-n
 return f if f>0 and not f in(a(i)for i in range(n))else a(n-1)+n

Obfuscated code :

def a(n):
 ###n####0######n#0
 f=a#######
 return f #f#####a###### f ####a(##f###i#i###a####n##else a#######

Outputs:

>>> a(0)
0
>>> a(4)
2
>>> a(16)
8
>>> a(20)
42

FliiFe

Posted 2016-04-09T00:57:38.500

Reputation: 543

Exactly what I had. Expected it to be easy, honestly. – CAD97 – 2016-04-10T21:12:13.997

1

C (71 bytes) by mIllIbyte

The sequence is floor(n/4).

x;f(_){x/=4;
    }
main(){
 scanf("%d",&x);
 f( 6);
 printf("%d", x);
}

feersum

Posted 2016-04-09T00:57:38.500

Reputation: 29 566

1

Python 3 (58 bytes) by CAD97

The sequence is A062318. There were a lot of unnecessary characters in this one, so I commented some out.

a=lambda n: ~-( -~(n%2)
# if ###### else 
*3**(n//2))#)##)

feersum

Posted 2016-04-09T00:57:38.500

Reputation: 29 566

The original was the slightly more literal a=lambda n:int(3**(n/2)-1 if n%2==0 else 2*3**(n/2-1/2)-1), but this works as well and is golfier. GG – CAD97 – 2016-04-11T03:51:10.563

1

Ruby, 11 bytes, histocrat, A011765

It only needs 5...

->i{i%4/3 }

I'd like to note though that the sequence is off-by-one compared to OEIS (which specifies that the first term corresponds to A(1)).

Martin Ender

Posted 2016-04-09T00:57:38.500

Reputation: 184 808

Argh, could've sworn I checked for solutions of that form. Also, sorry, yes, didn't notice the offset on the sequence entry. – histocrat – 2016-04-11T20:25:43.610

1Intended solution: i[i%2] (the (i mod 2)th least significant bit of i) – histocrat – 2016-04-11T20:29:15.187

@histocrat neat, I didn't even know bits could be indexed like that. :) – Martin Ender – 2016-04-11T20:31:13.063

1

Haskell, 51 bytes, Zgarb, A063866

f e=sum[1|1<-sum<$>mapM(flip(:)=<<pure.(0-))[1..e]]

Output: map f [0..6]: [0,1,1,0,0,3,5].

nimi

Posted 2016-04-09T00:57:38.500

Reputation: 34 639

1

05AB1E, 5 bytes, Adnan, A102669

Code:

TA«-g

Output:

a(0) = 0
a(1) = 0
a(2) = 1
a(3) = 1
a(4) = 1
a(5) = 1
a(6) = 1
a(7) = 1
a(8) = 1
a(9) = 1
a(10) = 0
a(11) = 0

Too bad you have designed the language in this inconvenient way.

jimmy23013

Posted 2016-04-09T00:57:38.500

Reputation: 34 042

Wow, I did not see that coming haha. The original code was 0K1Kg. – Adnan – 2016-04-12T13:24:57.740

1

Python, 17 bytes, ASCIIThenANSI, A000027

def a(n):return n

Trivial?

Blue

Posted 2016-04-09T00:57:38.500

Reputation: 26 661

1

Python, 60 bytes, ASCIIThenANSI A000930

def a(n):
 if n<3:
  return 1
 else:
  return a(n-1)+a(n-3)

Still trivial

Blue

Posted 2016-04-09T00:57:38.500

Reputation: 26 661

1

05AB1E, (4 bytes) by Adnan

The sequence is A126804, and the code to produce it is

D·ŸP

Try it online

I've never even looked at a program in 05AB1E before, it looks like a pretty cool language!

David

Posted 2016-04-09T00:57:38.500

Reputation: 1 316

Very nice! That was the exact same solution :) – Adnan – 2016-04-13T12:10:47.307

1

Lua, 45 bytes, Katenkyo, A001477

a=function(n)return n-1<1 and 0or 1+a(n-1)end

Leaky Nun

Posted 2016-04-09T00:57:38.500

Reputation: 45 011

1

Swift, 55 bytes, Nefrin, A103847

The sequence is McCarthy's 91 Function.
It takes the value 91 for any n up to 101 and then continues with 92,93,94 ...

I wonder what it's actually useful for.

func M(n:Int)->Int{
return(n<=100) ?M(M(n+11)):n-10;
}

Emigna

Posted 2016-04-09T00:57:38.500

Reputation: 50 798

1

05AB1E, 28 bytes, Lause, A256861

Code:

DD>D>D>D>****sD<*6+*6n2n5**/

Explanation:

              # implicit n on stack
DD>D>D>D>     # save n,n+1,n+2,n+3,n+4 on the stack
****          # multiply top 5 on stack together
              #     new stack: n,n(n+1)(n+2)(n+3)(n+4)
sD<*          # rotate, duplicate, decrease, multiply
              #     new stack: n(n+1)(n+2)(n+3)(n+4),n(n-1)
6+*           # add 6 to stack, add top 2, multiply top 2
              #     new stack: n(n+1)(n+2)(n+3)(n+4)(n(n-1)*6)
6n2n5**       # add 720 to stack
/             # divide
              # implicitly print n(n+1)(n+2)(n+3)(n+4)(n(n-1)*6)/720

Emigna

Posted 2016-04-09T00:57:38.500

Reputation: 50 798

1

Jolf, 3 bytes, Cᴏɴᴏʀ O'Bʀɪᴇɴ, A091940

+QQ

Test it here.

Since the output is off-by-one, the second formula on OEIS reduces to n + n^4. Where we implement n^4 by squaring the input twice.

Martin Ender

Posted 2016-04-09T00:57:38.500

Reputation: 184 808

Oh, this wasn't it. What does off-by-one mean? I think I messed it up – Conor O'Brien – 2016-04-17T21:03:37.240

@CᴏɴᴏʀO'Bʀɪᴇɴ It means that the number you get for a(23) is actually A091940(24). But this code matches all 4 test cases in your cop post, so whether or not this was your original code, I think it's a valid crack. – Martin Ender – 2016-04-17T21:06:03.447

Okay then. Nice job! – Conor O'Brien – 2016-04-17T21:06:38.257

1

05AB1A, 4 bytes, Adnan, A001127

Code:

$FÂ+

Explained:

$          # push 1 and input
 F         # input number of times, do:
  Â        # duplicate and reverse
   +       # add

The sequence starts at 1 and continues by adding the current number to its reverse.

0: 1
1: 1+1 = 2
2: 2+2 = 4
3: 4+4 = 8
4: 8+8 = 16
5: 16+61 = 77
6: 77+77 = 154
7: 154+451= 605
and so on...

Emigna

Posted 2016-04-09T00:57:38.500

Reputation: 50 798

1

05AB1E, 3 bytes, Emigna, A022559

Code:

!ÓO

Explanation:

!    # Compute the factorial of the implicit input.
 Ó   # Compute the exponents of the prime factors.
  O  # Sum that up together.

Resulting into A022559. Try it online!

Adnan

Posted 2016-04-09T00:57:38.500

Reputation: 41 965

1

05AB1E, 1 byte, mnbvc, A004085

Code:

Õ

Sequence is the sum of digits of Euler totient function of n.

Emigna

Posted 2016-04-09T00:57:38.500

Reputation: 50 798

1

LiveCode, 35 bytes, mnbvc, A001477

I/O:

oeis (0) = 0
oeis (2) = 2

Code:

function oeis n
    return n*1
End oeis

Sequence returns the non-negative integers.

Emigna

Posted 2016-04-09T00:57:38.500

Reputation: 50 798

1

Python, 37 bytes, mnbvc, A000290

I/O:

a(2) = 4
a(4) = 16

Code:

def a(n):
    return n*n#__!______n____*_

Sequence return square of input

Emigna

Posted 2016-04-09T00:57:38.500

Reputation: 50 798

1

05AB1E, 3 bytes, Emigna, A002994

Code:

3m¬

Explanation:

3m   # Compute input ** 3
  ¬  # Take the first digit

This gives us the initial digits of the cubes, which is A002994.

Uses CP-1252 encoding. Try it online!.

Adnan

Posted 2016-04-09T00:57:38.500

Reputation: 41 965

1

05AB1E, 8 bytes, Emigna, A088666

Code (with obfuscated version below):

4m1s+rT%
___s_r__

Explanation:

4m         # Compute input ** 4
  1        # Add one to the stack
   s       # Swap the top two elements
    +      # Add the two numbers (result = input ** 4 + 1)
     r     # Reverse the stack
      T    # Add 10
       %   # Modulo

This comes down to the formula a(n) = (n4 + 1) % 10, which is A088666. I'm excited to see what the original code was.

Try it online!.

Adnan

Posted 2016-04-09T00:57:38.500

Reputation: 41 965

0

J, 8 bytes, Kenny Lau, A057427

Code:

(>1-*)<.

Output:

a(0) = 0
a(i) = 1 for 0 < i < 30

The sequence is simply signum(n). The program computes floor(n) > 1 - signum(floor(n)), which is signum(n) for non-negative integers n.

Zgarb

Posted 2016-04-09T00:57:38.500

Reputation: 39 083

0

Python 3, 50 bytes, CAD97, A004242

from math import    *
a=lambda n:ceil(1000*log(n))

Try it online

Output:

a(1) => 0
a(10) => 2303

Mego

Posted 2016-04-09T00:57:38.500

Reputation: 32 998

That was fast (though I honestly did not make it very difficult) – CAD97 – 2016-04-11T01:45:36.770

@CAD97 I got tripped up slightly because originally I was only importing ceil from math, because I forgot log was in math and not __builtins__. I liked that trick. :) – Mego – 2016-04-11T01:46:27.227

0

Python 2 (72 bytes) by Sp3000

There's an unbelievable amount of sequences starting with 1,2,3,6,9,18 from the 1 element. I was fortunate to find one on the 3rd page where these are the only 6 terms: Divisors of 18.

print[1,#((#y
2,3,6,9,#.####c###6#####16#.
18][#)#131963
~-input()#3
]#)

feersum

Posted 2016-04-09T00:57:38.500

Reputation: 29 566

Hmm... I have to say that is the right sequence, but I overlooked the idea that some of the characters could be replaced by newlines (probably got confused due to the rule changes early on). In any case, a crack is a crack. – Sp3000 – 2016-04-11T18:31:43.880

0

Pyth, 4 bytes, FliiFe, A000041

Code:

l./Q

Explanation:

 ./Q  # Calculate the paritions of Q (input)
l     # Take the length, which counts the number of partitions.

Try it here.

Adnan

Posted 2016-04-09T00:57:38.500

Reputation: 41 965

Now that I think of it, I could have written l./ with implicit imput. – FliiFe – 2016-04-16T15:42:35.180

0

JavaScript, 30 bytes, Aplet123, A002061

It's the sequence A002061:

Central polygonal numbers: n^2 - n + 1.

n=>Math.pow(n,!![]+!![])-(n-1)

See it in action on JSFiddle.

insertusernamehere

Posted 2016-04-09T00:57:38.500

Reputation: 4 551

0

Python, 123 bytes, ASCIIThenANSI, A089911

Code:

def f(n):
 if n<2:
  return n
 else:
  return f(n-1)+f(n-2)

def g(n):
 if n<2:
  return n
 else:
  return (f(n-1)+f(n-2))%12

The formula for this sequence is g(n) = f(n) % 12, whereas f(n) is the nth Fibonacci number.

This was actually a really nice puzzle! :)

Adnan

Posted 2016-04-09T00:57:38.500

Reputation: 41 965

0

Python 3, 58 bytes, Mega Man

import math;x=int(input());print(int(x/math.sqrt(5)*x**x))

The sequence is:

(x/√5)*(x**x)

Zach Gates

Posted 2016-04-09T00:57:38.500

Reputation: 6 152

0

Python, 42 bytes, TùxCräftîñg

def f(x):return x if x<2else f(x-1)+f(x-2)

This is the Fibonacci sequence.

Dennis

Posted 2016-04-09T00:57:38.500

Reputation: 196 637