@candh/

Recamán's sequence

Python

my implementation of the sequence from the new numberphile video https://www.youtube.com/watch?v=FGC5TdIiT9U&t=26s

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
hop = 1
curr = 0
visited = [0]

for _ in range(50):
	print(curr)

	if curr - hop > 0 and curr - hop not in visited:
		curr -= hop
	else:
		curr += hop

	visited.append(curr)
	hop += 1

# print(visited)