Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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
            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 ?