# Generate the DH series

I see from this SMBC comic that Zach Weinersmith is offering a generous 14 points to anybody who can find a way of generating the following series:

0, 1, 4, -13, -133, 52, 53, -155


Now, we all know that there are infinite ways of generating any given numeric series, so Zach is clearly just giving those points away. But what's the shortest code that will do it?

I'll be particularly impressed if anyone can beat 25 bytes, particularly in a non-golfing language, since that's what it takes to write the following reference implementation in Python:

0,1,4,-13,-133,52,53,-155


The output can be in whichever format works best for you:

1. a program that spits out plaintext representation of signed decimal numbers
2. an expression that evaluates to a static sequence of numeric objects with these values (as in my Python example)
3. an expression for f(n) that returns the nth value of the sequence. You can choose a zero-based or one-based convention for n as you wish and need not worry what the expression produces subsequent to the known elements. (By "expression" here, I mean let's not count the characters in the function prototype itself, and let's say you can assume n is pre-initialized.)

Longer sequences (including infinite sequences) are permitted provided the first 8 elements match Weinersmith's DH Series above. The ninth and subsequent elements, if present, can be anything at all.

# Jelly, 12 bytes

“ĊĊḊḢṬ3gƈ¢‘I


Try it online!

### Explanation

“ĊĊḊḢṬ3gƈ¢‘      String representing code points
I     Consecutive increments


# PHP, 75 Bytes

0-Indexing prints a underscore separeted string till the n th value

<?=+$e;for(;$i++<$argn;)echo _,$e+=[185,1,7-4*$e-log($e)^0,-17,-120][$i%5];  Try it online! ## Expanded <?=+$e; #Output zero 0 th value
for(;$i++<$argn;) # loop till reach input n
echo _,$e+=[185,1,7-4*$e-log($e)^0,-17,-120][$i%5];
# Output and assign the next value in sequence


1: plus 1

2: plus 7 minus 4 times last value minus natural logarithm of last value cast to int

3: minus 17

4: minus 120

0: plus 185

Natural logarithm

## PHP, 33 Bytes

prints a string representation

<?="[0,1,4,-13,-133,52,53,-155]";


Try it online!

# 05AB1E, 20 bytes

•3—ι]½ý.¢Σ”•6¡4'-:.¥


Try it online!

Uses: 16364176412061856164208

Replace the 6's with commas (split on 6): ['1', '3', '417', '4120', '185', '1', '4208']

Replace 4's with negative symbol: ['1', '3', '-17', '-120', '185', '1', '-208']

Undelta.

Simpler approach (turned out worse): •5Û€ïÛ†!eŽΓ•8BR7¡6'-:

# Jelly, 17 Bytes

153B-*“¡¢¥Æ⁵45ɓ‘×


Try it online!

Explanation:

153B-*


decode the signs from the binary digits of 153

“¡¢¥Æ⁵45ɓ‘


the magnitudes of the numbers represented as a code-page index list

×


elementwise multiplication

# 05AB1E, 14 bytes

"ÈÉÌ»Cüý-"ÇƵ%-


Try it online!

Explanation

"ÈÉÌ»Cüý-"      # push this string
Ç     # convert to code points
Ƶ%-  # subtract 200 from each


### Previous 15 bytes solution

•∍ÉΣ-ú—("o•3ô¬-


Try it online!

Explanation

•∍ÉΣ-ú—("o•       # push the number 1551561591420222072080
3ô     # split into pieces of 3
¬-   # subtract the first element from all elements

• Way better than mine, admittedly I just wanted to try using undelta. – Magic Octopus Urn Jun 5 '17 at 18:32
• @carusocomputing: Yeah I'm glad you did. I was unsure what it was until I saw you answer :) – Emigna Jun 5 '17 at 18:33

## Mathematica, 79 bytes

s={-22,-83,408,-489,-25};i=2;While[i!=-1,t=Join[{i},Accumulate[s]+i];i--;s=t];s


Try it online!

in order to run on mathics the original code needs 2 more bytes

# Python 3, 37 bytes

for i in 'ÝÞáÐXđĒB':print(ord(i)-221)

• That is great—I fiddled with that approach briefly myself but couldn't get there. Note that you could make it a list comprehension and ditch the print to achieve a result of type 2 – jez May 27 '17 at 1:33
• Welcome to the site! You don't need the space after the in. – Sriotchilism O'Zaic May 27 '17 at 1:37
• Or say ord('ÝÞáÐXđĒB'[n])-221 for an even shorter answer, of type 3 – jez May 27 '17 at 1:39
• This works nicely, but Python only supports non-UTF-8 encodings with a magic comment (which would have to be counted towards the score). With UTF-8, your code is 43 bytes long. – Dennis May 27 '17 at 8:03
• You can remove a space between in and the string, so i in'ÝÞá – sagiksp Jun 5 '17 at 16:11

# Neim, 11 + 1 (-n) = 12 bytes (non-competing)

0γ4π𝐍𝐲𝐍./𝕥𝐍


Try here

Note: might not work in the future. For reference, this works for commit db32a5e.

Explanation:

0γ4π𝐍𝐲𝐍./𝕥𝐍 Push 0
γ          Push 1
4         Push 4
π        Push 13
𝐍       Negate
𝐲      Push 133
𝐍     Negate
.    Push 52
/   Push 53
𝕥  Push 155
𝐍 Negate