[Question]
  [
**This is the cops' thread. The robbers' thread goes [here](https://codegolf.stackexchange.com/questions/77420/find-the-program-that-prints-this-integer-sequence-robber-thread).**
The last [cops-and-robbers](/questions/tagged/cops-and-robbers "show questions tagged 'cops-and-robbers'") thread was already [4 months ago](https://codegolf.stackexchange.com/questions/67756/printing-ascending-ascii-cops).
## The cop's task
* The cop's task is to write a program/function that takes a positive (or non-negative) integer and outputs/returns another integer.
* **The cop must state it if the program is intolerant towards zero.**
* The cop will provide at least **2** sample inputs/outputs.
* For example, if I have decided to write the [Fibonacci sequence](https://en.wikipedia.org/wiki/Fibonacci_number), I would write this in my answer:
```
a(0) returns 0
a(3) returns 2
```
* The number of examples is up to the cop's discretion.
* However, the sequence must actually exist in [the On-Line Encyclopedia of Integer Sequences®](http://oeis.org/), so no pseudo-random number generator for you. `:(`
* **The cop can hide as many characters as is so wished.**
* For example, if my program is:
---
```
function a(n)
    if n>2 then
        return n
    else
        return a(n-1) + a(n-2)
    end
end
```
---
* Then I would hide these characters as I want:
---
```
function a(n)
    if ### then
        ########
    else
        ######################
    end
end
```
---
## The robber's task
* is obviously to find the original source code.
* **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.**
---
## Tips for the cops
* ~~The search function in the OEIS only works for consecutive terms, so if you want to hide your sequence, then just leave a hole anywhere.~~
* Apparently there is no way to hide the sequence. Put this in mind when you choose the sequence.
---
Your score is the number of bytes in your code.
The winner will be the submission with the lowest score that hasn't been cracked in 7 days.
Only submissions that are posted in 2016 April are eligible for the win. Submissions that are posted later than this are welcome, but cannot win.
In order to claim the win you need to reveal the full code and the OEIS sequence (after 7 days).
Your post should be formatted like this (NN is the number of characters):
---
# Lua, 98 bytes
Output:
```
a(0) returns 0
a(3) returns 2
```
Code (`#` marks unrevealed characters):
```
function a(n)
    if ### then
        ########
    else
        ######################
    end
end
```
---
If the code is cracked, insert `[Cracked](link to cracker)` in the header.
If the submission is safe, insert "Safe" in the header and reveal the full code in your answer. Only answers that have revealed the full code will be eligible for the win.
  
[Answer]
# Vim, 36 keystrokes -- Safe!
```
i****<esc>:let @q="^*i****$**@***"<cr><n>@qbD
```
(Note: `<n>` is where you type your input)
Here is the code unrelated to number generation:
```
          :let @q="              "<cr><n>@qbD
```
Meaning I am revealing 5 out of 19 characters.
`<n>` is the input. Here are some sample outputs:
```
1@q:    1
2@q:    3
6@q:    18
```
# Answer
This code prints The Lucas Numbers ([A000032](https://oeis.org/A000032)), which are just like The Fibonnaci Sequence, except that it starts on `2, 1` instead of `1, 1`. Here are the first 15 numbers:
```
2, 1, 3, 4, 7, 11, 18, 29, 47, 76, 123, 199, 322, 521, 843
```
Here's the revealed code:
```
i2 1 <esc>:let @q="^diwwyw$pb@-<c-v><c-a>"<cr><n>@qbD
```
Explanation:
```
i2 1 <esc>                          "Insert the starting numbers
          :let @q="....."<cr>       "Define the macro 'Q'
```
Explanation of the macro:
```
^                      "Move to the first non-whitespace character on the line.
 diw                   "(d)elete (i)nner (w)ord. This is different then 'dw' because it doesn't grab the space. 
                      "It also throws people off since 'i' is usually used for inserting text.
    wyw$               "Move to the next number, yank it then move to the end of the line 
        pb             "(p)aste the yanked text and move (b)ack
          @-     <c-a> "@- is the register holding the word we deleted. Increment the current number that many times.
            <c-v>      "Since we're adding <c-a> this from the command line, we need to type it as a literal.
```
Now, we just need to remove the second number, since the first number is the lucas number we want. So we do
```
b   "move (b)ack
 D  "(D)elete to the end of the line.
```
Also, if I'm not mistaken, this is the first safe submission! That's kinda cool.
[Answer]
# [05AB1E](http://github.com/Adriandmen/05AB1E), 5 bytes, safe
Last one for today :p. Output:
```
a(0) = 9
a(5) = 4
a(10) = 89
```
Code:
```
___m_
```
Obfuscated characters are indicated with `_`. [Try it online!](http://05ab1e.tryitonline.net/)-link. Uses **CP-1252** encoding.
---
### Solution:
```
žhžm‡
```
Explanation:
```
žh       # Short for [0-9].
  žm     # Short for [9-0].
    ‡    # Translate.
```
[Try it online!](http://05ab1e.tryitonline.net/#code=xb5oxb5t4oCh&input=MA) or [Try for all test cases!](http://05ab1e.tryitonline.net/#code=W0nFvUQiYSjDvykgPSAic8W-aMW-beKAocKrLA&input=MAo1CjEw).
[Answer]
# [Element](https://github.com/PhiNotPi/Element), 7 bytes, [cracked](https://codegolf.stackexchange.com/a/77439/48934)
Output:
```
a(3) = 111
a(7) = 1111111
```
The `#` are hidden characters, and they are all printable ASCII. I think this one is actually reasonably difficult (for only having 5 missing characters).
```
###,##}
```
For convenience, here's the [Try It Online](http://element.tryitonline.net/) and [Esolang wiki](https://esolangs.org/wiki/element) pages.
---
My original program was:
> 
>  `_'[,$`}`
> 
> 
> 
The trick is that
> 
> `]` and `}` are functionally identical (both translate to `}` in Perl). Also, I used `,$` to produce a `1` as an additional layer of confusion, although it is possible to ignore the `,` completely by doing `,1` instead.
> 
> 
> 
[Answer]
# [Jolf](https://github.com/ConorOBrien-Foxx/Jolf), 5 bytes, [cracked](https://codegolf.stackexchange.com/a/77422/31957)
Output:
```
a(2) = 8
a(10) = 4738245926336
```
All of it is crucial, and I have shown 1 of 5.
```
####x
```
Original code:
```
mPm$x
mP     cube
  m$   catalan number
    x  input
```
[Try it online!](http://conorobrien-foxx.github.io/Jolf/#code=bVBtJHg&input=MTA)
[Answer]
# JavaScript (ES7), 10 bytes, [Cracked](https://codegolf.stackexchange.com/a/77756/46855)
### Output
```
f(0) -> 1
f(1) -> -1
```
### Code
```
t=>~t##**#
```
**Test it in Firefox nightly.** The code is an anonymous function. This will probably be easy since there's only three characters hidden, but at least it's short! :P
---
My original code was:
> 
>  `t=>~top**t`
> 
> 
> 
but after brute-forcing my own code for a solution, I soon realised
> 
>  `t=>~t.x**t` (where `x` can be any variable name character)
> 
> 
> 
could also be used. This works because
> 
>  in the original ES7 exponentiation operator spec, the operator had lower precedence than unary operators (unlike conventional mathematics and most other languages). `~` performs a bitwise NOT on `t.x` (`undefined`) or `top` (`Object`) which casts them to a 32-bit signed integer (uncastables like these become `0`) before doing the NOT (so `0` becomes `-1`). I looked into further into this, and very recently, the spec has changed to disallow ambiguous references like this (not good for future golfing D: ), however most ES7 engines haven't updated to the latest version of the spec yet.
> 
> 
> 
[Answer]
## 05AB1E, 4 bytes ([Cracked](https://codegolf.stackexchange.com/a/77447/34388))
Sample output :
```
a(5) = 51
a(8) = 257
```
And for the code :
```
###^
```
I revealed the last one. Should be easy enough though, I had quite a hard time finding a sequence :(
All hidden characters are printable.
[Answer]
# [MATL](http://matl.tryitonline.net), 5 bytes, [cracked](https://codegolf.stackexchange.com/a/77479/36398)
Hidden characters are indicated by `%`.
```
%5%*%
```
Output:
```
a(1) = 3
a(2) = 6
a(4) = 12
```
Input `0` is valid.
---
Original code:
```
35B*s
```
that is,
```
35    % push number 35
B     % convert to binary: array [1 0 0 0 1 1]
*     % multiply element-wise by implicit input n: gives [n 0 0 0 n n]
s     % sum of array: gives 3*n
```
[Answer]
# SWIFT, 55 bytes, [Cracked](https://codegolf.stackexchange.com/questions/77420/find-the-program-that-prints-this-integer-sequence-robbers-thread/77765#77765)
```
func M(n:Int)->Int{
return(n*****) ?M(**n****):n***;
}
```
`*` marks a hidden character
Output:
```
M(30) -> 91
M(60) -> 91
M(90) -> 91
M(120)-> 110
M(150)-> 140
```
Function accepts `0`
[Answer]
# Ruby, 46 bytes, safe
Edit to add disclaimer/apology: This sequence starts with f[0], while the OEIS entry starts with f[1]. The values are the same.
Obfuscated code (`#` is any character):
```
->####or x##1###(#..##0#);x*=3;end;#.###ect:+}
```
Call like
```
->####or x##1###(#..##0#);x*=3;end;#.###ect:+}[3] (returns 39)
```
Output:
```
f[0] = 0
f[1] = 3
f[2] = 12
f[3] = 39
f[4] = 120
f[5] = 363
f[6] = 1092
f[7] = 3279
f[8] = 9840
f[9] = 29523
```
Solution:
> 
>  `f=->*x{for x[-1]in(0..x[0]);x*=3;end;x.inject:+}`
> 
> 
> 
Sequence:
> 
>  <http://oeis.org/A029858>
> 
> 
> 
Explanation:
> 
>  The minor trick here is that we declare the parameter as `*x` rather than `x`. This means that if you pass in `2`, `x` is set to `[2]`...at first. The *major* trick exploits bizarre, and justly obscure, Ruby syntax where you can set the iterator in a for loop to any valid left hand side of an assignment expression, instead of an iterator variable like `i`. So this loops through from 0 to (in this example) 2, assigning each number to `x[-1]`, meaning it overwrites the last value of x. Then the loop body `x*=3`, further mutates x by concatenating it to itself 3 times. So first x becomes `[0]`, then `[0,0,0]`. On the next loop it becomes `[0,0,1]`, then `[0,0,1,0,0,1,0,0,1]`. Finally we pass in 2 and it becomes `[0,0,1,0,0,1,0,0,2]`, then `[0, 0, 1, 0, 0, 1, 0, 0, 2, 0, 0, 1, 0, 0, 1, 0, 0, 2, 0, 0, 1, 0, 0, 1, 0, 0, 2]`. We then sum the result using the `inject` method, which reduces the array by applying `+` (the passed in method) to each element in turn. If we consider how each iteration changes the sum, we see that we effectively add 1 (by overwriting the last element with an element one higher), then multiply by 3. Since `3*(n+1) = 3*n + 3`, this implements Alexandre Wajnberg's recurrence relation for the sequence as described on the page.
> 
> 
> 
[Answer]
# [05AB1E](http://github.com/Adriandmen/05AB1E), 3 bytes, [cracked](https://codegolf.stackexchange.com/a/77444/48934)
Output:
```
a(9) = 165
a(10) = 220
```
Hidden code:
```
##O
```
[Try it online](http://05ab1e.tryitonline.net/#code=IyNP&input=NQ) might come in handy.
[Answer]
# [Hexagony](http://github.com/mbuettner/hexagony), 7 bytes, [cracked](https://codegolf.stackexchange.com/a/77446/34388)
Output:
```
a(1) = 2
a(2) = 4
```
Hidden code:
```
?#####@
```
Or alternatively:
```
 ? #
# # #
 # @
```
[Try it online](http://hexagony.tryitonline.net/) might come in handy.
[Answer]
# PHP, 41 bytes, [cracked](https://codegolf.stackexchange.com/a/77466/41859)
Yeah, finally another Cops and Robbers challenge. Hope I didn't make it to easy.
**Output**
```
a(5)   = 0
a(15)  = 1
a(35)  = 0
a(36)  = 1
a(45)  = 1
```
**Source**
```
____________________$argv[1]____________;
####################        ############
```
**Notes**
* It's a full program, not a function.
* Reads the input from command line (obviously).
* [Does not contain any PHP opening tag](http://meta.codegolf.stackexchange.com/questions/7098/is-the-php-opening-tag-mandatory-in-byte-count).
---
**Cracked**
I obviously made it to easy and provided not enough examples. The sequence I had in mind was [A010054](https://oeis.org/A010054):
> 
> a(n) = 1 if n is a triangular number else 0.
> 
> 
> 
Here's my original source code:
> 
>  `echo(int)($r=sqrt(8*$argv[1]+1))==$r?1:0;`
> 
> 
> 
It tests whether the input is a *triangular number* and outputs `1` or `0` accordingly.
[Answer]
# Jolf, 11 bytes, [Cracked](https://codegolf.stackexchange.com/questions/77420/find-the-program-that-prints-this-integer-sequence-robbers-thread/77491#77491) , [A011551](https://oeis.org/A011551)
```
c*______x__
c*mf^+91x~P
```
Original code:
```
c*^c"10"x~P
```
Examples:
```
0 -> 1
12 -> 1618033988749
```
[Answer]
# MATL, 9 bytes, [Cracked](https://codegolf.stackexchange.com/a/77494/42892)
Code:
```
3#2###*##
```
Output:
```
a(1)  = 3
a(2)  = 6
a(4)  = 12
a(12) = 37
```
`a(0)` is valid.
---
### Cracked
Original sequence:
[A059563](https://oeis.org/A059563)
Original code:
```
3L2^Ze*sk
3L          % Push [1 -1j] from the clipboard
  2^        % square
    Ze      % exp
      *     % times input
       s    % sum
        k   % floor
```
[Answer]
# Java, 479 bytes, [Cracked](https://codegolf.stackexchange.com/a/77497/41505)
Outputs:
```
a(10) = 81
a(20) = 35890
```
(Inputs are provided via command line arguments)
Code (`#` marks hidden characters):
```
import java.util.*;
public class A{
    public static int#########
    public boolean###########
    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; ################if(##>##{
            ###########d#
            #######+##p##########+##########(#######
        }
        System.out.println(#########################
            ###(A.#############(#5#####)));
    }
}
```
The program starts at index 0.
(Note that SE replaces all of the `\t` indents with 4 spaces, bringing the byte total to 569. Click [here](https://goo.gl/4yS0Ff) to see the program with `\t` indents instead of space indents.)
Original code:
```
import java.util.*;
public class A{
    public static interface B{
    public boolean C(int i);} 
    
    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++)cif(i->  {
            return l.add(
            l.pop()+l.peekFirst()+l.peekLast());});{    
        }
        
        System.out.println(l.get(1));}static boolean 
            cif(A.B b5){return (b5.C((0)));
    }
}
```
(Same code, but formatted normally):
```
import java.util.*;
public class A {
    public static interface B { //functional interface for lambda expression
        public boolean C(int i); //void would have given it away
    }
    static A a = new A(); //distraction
    public static void main(String[] args) {
        int input = Integer.parseInt(args[0]);//Input
        LinkedList<Integer> l = new LinkedList<>();
        l.add(1);//Set up list
        l.add(0);
        l.add(0);
        for (int ix = 0; ix < input; ix++)
            cif(i -> { //Fake if statement is really a lambda expression
                return l.add(l.pop() + l.peekFirst() + l.peekLast());
            });
        { //Distraction
        }
        System.out.println(l.get(1));//Output
    }
    static boolean cif(A.B b5) { //Used to pass in lambda expression.
                  //The A. and b5 were both distractions
        return (b5.C((0)));
    }
}
```
[Answer]
# Octave, 34 bytes, [cracked](https://codegolf.stackexchange.com/a/77532/31516)
```
@(m)(m###m#####m##)&isprime(#)####
```
Outputs:
```
ans(1) = 0
ans(6) = 5
ans(7) = 10
ans(8) = 15
```
The sequence starts at `ans(1)` in OEIS.
[Answer]
# C, 71 bytes [cracked](https://codegolf.stackexchange.com/a/77549/52554)
```
############
#####
main(){
 scanf("%d",##);
 ###6#;
 printf("%d",##);
}
```
Output:
```
a(1) = 0   a(2) = 0   a(5) = 1
a(6) = 1   a(7) = 1   a(9) = 2
```
This works with gcc, and is a full program. It accepts 0 as input.
[Answer]
## Pyth, 70 bytes, [Cracked](https://codegolf.stackexchange.com/a/77530/34388)
```
DhbI|qb"#"qb"#"R!1Iqb"#"#####+""s####2###;##lY+Q1Ih+""Z#####)=Z+Z1;@YQ
```
`#` are the hidden characters
Has been cracked, so here is the versionn without hidden chars :
```
DhbI|qb"4"qb"0"R!1Iqb"1"R!0Rh+""sm^sd2cb1;W<lY+Q1Ih+""Z=Y+YZ)=Z+Z1;@YQ
```
Sample outputs :
```
a(2) -> 10
a(4) -> 19
```
~~Good luck to find this on OEIS, I personally failed to find it from those examples (even tho the sequence is quite easy to spot.)~~
[Answer]
# Ruby, 38 bytes, [cracked](https://codegolf.stackexchange.com/a/77621/6828)
Obfuscated code (`#` can be any character):
```
->#{(s=#########).sum==#3333&&eval(s)}
```
Output:
Multiplies the input by 10 (A008592). Works for any integer, including 0. e.g.
```
->#{(s=#########).sum==#3333&&eval(s)}[3]  => 30
->#{(s=#########).sum==#3333&&eval(s)}[10] => 100
```
[Answer]
# [05AB1E](http://github.com/Adriandmen/05AB1E), 5 bytes, [cracked](https://codegolf.stackexchange.com/a/77680/34388)
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
```
Obfuscated code:
```
_____
```
[Try it online!](http://05ab1e.tryitonline.net/)-link.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 4 bytes, [cracked](https://codegolf.stackexchange.com/a/77708/34388)
Well then, I think I'm addicted to CnR's... Obfuscated code (`_` indicates a wild card):
```
____
```
Sequence:
```
a(1) = 2
a(4) = 6720
```
The sequence in **OEIS** starts at a(1) = 2.
[Try it online!](http://05ab1e.tryitonline.net/)-link
[Answer]
## Lua, 45 Bytes, [Cracked](https://codegolf.stackexchange.com/a/77763/41019)
A small hint:
```
a(0) will make the program crash :)
```
### Output
```
a(1)=>0
a(2)=>1
```
### Code
Uses `#` to hide the code :).
```
a=function(n)#####n###### and #or ########end
```
I was using the OEIS [A007814](http://oeis.org/A007814), with the following code:
```
a=function(n)return n%2>0 and 0or 1+a(n/2)end
```
[Answer]
## [Pyke](http://pyke.catbus.co.uk), 15 bytes, SAFE
Output
```
a(2) = 21
a(15) = 17
```
Revealed code:
```
#R#D######+##)#
```
Solution:
> 
>  OEIS [A038822](https://oeis.org/A038822)
>   
> 
> `wR}DSR_Q*L+#P)l`
>   
> 
>  I used a couple of red herrings here by using `wR}` to generate the number 100 and revealing the character `R` which is normally used to rotate the stack. I also used `#P)l` instead of the more simple `mPs` to count the number of primes in the sequence.
> 
> 
> 
[Answer]
# C, 82 bytes, safe
```
####=############
main(i){scanf("%d",##);
for(i=1;i++/4<#;)##=2;
printf("%d",##);}
```
Works with gcc, and it is a full program, which reads its input from stdin and prints its output to stdout. Here the sequence is ~~A004526, floor(n/2)~~.
```
a(0) = 0    a(1) = 0    a(2) = 1
a(3) = 1    a(4) = 2    a(5) = 2
a(6) = 3    a(7) = 3    a(8) = 4
```
**Solution:**
```
a;*b=(char*)&a+1;
main(i){scanf("%d",&a);
for(i=1;i++/4<2;)a*=2;
printf("%d",*b);}
```
This works only on little endian machines, and only if the size of `char` is 1 byte.   
And only if the byte higher than the highest order byte of `a` has value 0. I think this is true for gcc since by default uninitialized global variables go into the bss segment, and initialized global variables go into the data segment (see <https://stackoverflow.com/questions/8721475/if-a-global-variable-is-initialized-to-0-will-it-go-to-bss>).  
 So only `a` goes into bss (the only other global variable `b` is initialized and thus goes into the data segment). If `a` is not at the end of bss, then the byte higher than the highest order byte of `a` is also in bss and thus has value 0.
[Answer]
## 05AB1E, 1 byte, Cracked
```
_
```
`_` denotes hidden code.
```
f(1) == 1
f(18) == 6
```
[Answer]
# [Element](https://github.com/PhiNotPi/Element), 10 bytes, [cracked](https://codegolf.stackexchange.com/questions/77420/find-the-program-that-prints-this-integer-sequence-robbers-thread/77433#77433)
Output:
```
a(3) = 6561
a(4) = 4294967296
```
There's probably only a few ways to compute this sequence in Element. I found a 9-char solution, but I figured this 10-char solution is actually more difficult. The `#` are hidden characters.
```
#_####@^#`
```
For convenience, here's the [Try It Online](http://element.tryitonline.net/) and [Esolang wiki](https://esolangs.org/wiki/element) pages.
---
The original was
```
2_3:~2@^^`
```
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 18 bytes
`#` marks unrevealed characters.
```
L?Jtb##5#m##S#2 #y
```
Outputs (starts from `1`):
```
1 -> 2
2 -> 3
3 -> 5
4 -> 7
```
[Online interpreter](http://pyth.herokuapp.com/)
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 5 bytes, [cracked](https://codegolf.stackexchange.com/a/77462)
I hope that this submission isn't as easy as my other ones :p. Outputs:
```
a(0) = 0
a(1) = 1
a(2) = 6
a(3) = 24
a(4) = 80
a(5) = 240
```
Obfuscated code:
```
####O
```
Contains some non-ASCII characters though, uses **CP-1252** encoding.
[Try it online!](http://05ab1e.tryitonline.net/) might come in handy :p.
[Answer]
# [Jolf](https://github.com/ConorOBrien-Foxx/Jolf), 11 bytes, [Cracked](https://codegolf.stackexchange.com/a/77460/31541).
Output:
```
a(10) = 4
a(20) = 6
a(30) = 8
```
And the partially hidden code:
```
####xd###x#
```
Hint: 
> 
>  When I looked through the sequences in order, I didn't go very far before finding this one. 
> 
> 
> 
The cracked version isn't quite the same as my original code. I'm not currently at my computer, so I don't have it exactly, but it was something like this: 
> 
>  `l fzxd!m%xH`
> 
> 
> 
(The only part I'm unsure about is the `!m`. It's whatever checks if a variable is zero.)
[Answer]
## [Pyke](http://pyke.catbus.co.uk), 6 bytes, [Cracked](https://codegolf.stackexchange.com/a/77478/32686)
```
###X#s
```
Output:
```
a(2) = 8
a(8) = 80
a(10) = 120
```
This doesn't work with N<1
Original solution:
> 
>  `hSmX$s`
> 
> 
> 
]