Output of a sequence in Display and as a txt-File
Hello. This
X = 19 # Start
N = 7 # Width
def f(x, n):
yield x
for k in range(0, n):
if x % 2 == 0:
x = x / 2
else:
x = 3*x + 1
yield x
print(", ".join(map(str, f(X, N))))
gives me a sequence comma-separated in the display.
How can I have that line-separated (like at default) as a good-named txt-File, like collatz19.txt
?