Make your program sequential!
Python 2, 35 Bytes
I decided to use the obvious sequence A000027, which essentially has the formula n
;) If you run the following code:
#print'n'
n=1
exec'print n;n+=1;'*8
You get the output:
1
2
3
4
5
6
7
8
And if you take the 8 characters from my source code (0-indexed), you get this:
print'n'
Which simply prints n
.
If you were hoping for a more exciting answer, here's a Python 2 solution for n^2
, i.e. A000290:
#p r i n t ' n ^ 2 '
n=1
exec'print n*n;n+=1;'*10
05AB1E, 7 6 bytes, A000027
5L'n s
Try it online!
Explanation:
5L # Push [1, 2, 3, 4, 5]
'n # Push "n"
# Do nothing
s # Swap (only in original program)
# Implicit print
Octave, 64 bytes A000290
I went for the n^2
one:
@()(1:5 ).^2 % ' n ^ 2 '
Take the terms 1, 4, 9, 16, 25, 36, 49 and 64 to get:
@()'n^2'
which prints:
n^2