The origin of the following question is irrelevant and will hence be skipped. Hopefully, it will be interesting without context.
Consider the following algorithm. We will use $p_i$ to denote the $i$-th prime.
We start with $m_k=p_k$. For $i=k−1$ down to $1$, let $m_i$ be the smallest multiple of $p_i$ greater than $m_{i+1}$ that is not divisible by any prime less than $p_i$. This goes upto the smallest prime, $p_1=2$. For example, if we start with $p_4=7$, then $m_3=25$, $m_2=27$ and $m_1=28$. Similarly, if we start with $p_5=11$, then $m_1=58$.
My question is whether we can tell anything about the asymptotics of the growth of $m_1$ better than the crude approximate (which only uses the fact that out of $P_m=p_1p_2\dots p_m$ integers, at least one will be divisible by $p_m$ and coprime to the rest of the primes below it), which is useless. I did some computations and I believe that $m_1$ is in $\mathcal O(p_k^2)$ although I do not have any idea how it might be possible to achieve that.
After trying to do some research, I came to know about the Jacobsthal function $j(n)$ which is defined as the smallest positive integer $m$, such that every sequence of $m$ consecutive integers contains an integer coprime to $n$. This is slightly different from what we are after. We want an integer coprime to $p_{i-1}\#$ as well as divisible by $p_i$ (where $p\#$ is the product of all primes less than or equal to $p$, also known as the primorial). I came to know about Iwaniec's result that $$j(n)\ll (\log n)^2 \implies j(p_n\#)\ll (n\log n)^2$$ but I am not sure whether it is possible to use the Jacobsthal function in our case.
Here's a code (by DeepSeek) in case anyone is interested.
import math
def is_prime(n):
if n < 2:
return False
if n == 2:
return True
if n % 2 == 0:
return False
for i in range(3, int(math.isqrt(n)) + 1, 2):
if n % i == 0:
return False
return True
def prev_prime(p):
q = p - 1
while q >= 2:
if is_prime(q):
return q
q -= 1
return None
def generate_sequence(p):
if not is_prime(p):
raise ValueError("Input must be a prime number")
current = p
sequence = [current]
print(f"Step 0: p = {p} → {current}")
step = 1
q = prev_prime(p)
while q is not None:
# Find smallest multiple of q greater than current
k = current // q + 1
candidate = k * q
# Find all primes smaller than q
small_primes = [r for r in range(2, q) if is_prime(r)]
# Find next valid candidate
while True:
valid = True
for r in small_primes:
if candidate % r == 0:
valid = False
break
if valid:
break
k += 1
candidate = k * q
current = candidate
sequence.append(current)
print(f"Step {step}: q_{step} = {q}, m_{step} = {candidate} → {current}")
step += 1
q = prev_prime(q)
return sequence
# Get user input
try:
p = int(input("Enter a prime number: "))
seq = generate_sequence(p)
print("\nFinal sequence:", seq)
except ValueError as e:
print(e)