OFFSET
1,3
LINKS
Harvey P. Dale, Table of n, a(n) for n = 1..1000
EXAMPLE
a(3) = prime(1) - ceiling(a(1)/2) = 2 - ceiling(0/2) = 2,
a(4) = prime(2) - ceiling(a(2)/2) = 3 - ceiling(1/2) = 2,
a(5) = prime(3) - ceiling(a(3)/2) = 5 - ceiling(2/2) = 4,
a(6) = prime(4) - ceiling(a(4)/2) = 7 - ceiling(2/2) = 6,
a(7) = prime(5) - ceiling(a(5)/2) = 11 - ceiling(4/2) = 9.
MATHEMATICA
a[1] = 0; a[2] = 1; a[n_] := a[n] = Floor[(2*Prime[n - 2] - a[n - 2])/2]; Array[a, 100] (* Amiram Eldar, Sep 18 2020 *)
nxt[{n_, a_, b_}]:={n+1, b, Prime[n-1]-Ceiling[a/2]}; Join[{0, 1, 2}, Drop[NestList[nxt, {3, 2, 2}, 70][[All, 2]], 2]] (* Harvey P. Dale, May 13 2022 *)
PROG
(Ruby) require 'prime'
values = [0, 1]
Prime.each(100) do |prime|
values << prime - (values[-2]+1) / 2
end
p values
(PARI) a(n) = if (n<=2, n-1, prime(n-2) - ceil(a(n-2)/2)); \\ Michel Marcus, Oct 07 2020
CROSSREFS
KEYWORD
nonn
AUTHOR
Simon Strandgaard, Sep 17 2020
STATUS
approved