| 1 | initial version |
One way would be as follows:
with open('collatz_{}_{}.txt'.format(X, N), 'w') as file:
file.writelines(str(k) + '\n' for k in f(X, N))
Also, you could use x = x // 2 in your code to always work with integers rather than rational numbers.
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.