Skip to content

Instantly share code, notes, and snippets.

@JSeam2
Last active June 10, 2019 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JSeam2/445e47cb6a8a9dcf8d42412de36e911b to your computer and use it in GitHub Desktop.
Save JSeam2/445e47cb6a8a9dcf8d42412de36e911b to your computer and use it in GitHub Desktop.
Van Ecks Sequence python
#!/usr/bin/env python
"""
Sample code for van eck's sequence
"""
output = [0, 0, 1]
for i in range(2, 1000):
init_len = len(output)
last_val = output[i]
count = 1
for j in reversed(output[:-1]):
if j != last_val:
count += 1
continue
elif j == last_val:
output.append(count)
break
if len(output) == init_len:
output.append(0)
print(output)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment