Skip to content

Instantly share code, notes, and snippets.

@Drvanon
Last active December 21, 2015 17:18
Show Gist options
  • Select an option

  • Save Drvanon/6339091 to your computer and use it in GitHub Desktop.

Select an option

Save Drvanon/6339091 to your computer and use it in GitHub Desktop.
wonder_numbers = set([2])
temp_wonder_numbers = set()
def wonder(n):
n = int(n)
if n in wonder_numbers:
print('n is a wonder number')
for i in temp_wonder_numbers:
wonder_numbers.add(i)
return
if not(n % 2):
print(n, ' is an even number, so I will half it which is: ', int(n / 2))
temp_wonder_numbers.add(n)
wonder(n / 2)
else:
print(n, 'is an odd number so I will do it times three and append it with one: ', 3 * n + 1)
temp_wonder_numbers.add(n)
wonder(3 * n + 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment