Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Here is some code

a = {1: 1, 2: 2}
for n in range(3, 20):
    b = a[n - 1]
    if ZZ(b).is_prime():
        a[n] = 2 * b
    else:
        a[n] = b - 1
print(a)