Skip to main content
2 of 4
added 304 characters in body
Carlo Beenakker
  • 188.3k
  • 18
  • 448
  • 651

For the record (not an answer), the function $a(n-1,n)$ for $n$ up to $10^4$ contains 2264 distinct primes, the largest being equal to 20369. The growth rate of the primes is close to linear in $n$, see plot.

I also note the similarity with a known prime generating algorithm described in A natural prime-generating recurrence: $$b(n)=b(n-1)+\text{gcd}\,(b(n-1),n),$$ For small starting values $b(1)$ the difference $b(n)-b(n-1)$ is either 1 or prime.


Mathematica code

out=Table[{t=RecurrenceTable[{a[m]==a[m-1]+GCD[a[m-1],n-m],a[0]==n},a,{m, 1,n-1}];{n,t[[n-1]],PrimeQ[t[[n-1]]]}},{n,2,10000}]; And @@ out[[All,1,3]] ListPlot[out[[All,1,2]]]

Carlo Beenakker
  • 188.3k
  • 18
  • 448
  • 651