OFFSET
1,3
COMMENTS
In other words, a(n) is the smallest positive number that differs from the nearest multiple of prime(k) by at least floor(prime(k)/2) for each k in 1..n.
LINKS
David A. Corneth, PARI program
EXAMPLE
a(1)=1 because prime(1)=2, the nearest multiples of 2 to 1 are 0 and 2, and each differs from 1 by floor(2/2) = 1.
a(2)=1 as well because 1 satisfies not only the requirement regarding the distance from the nearest multiple of prime(1)=2 but also the additional requirement regarding the distance from the nearest multiple of prime(2)=3: the nearest multiple of 3 to 1 is 0, and |0-1| = 1 = floor(3/2) = 1.
a(3)=7 because prime(3)=5 and neither of the numbers smaller than 7 that differ from their respective nearest multiples of 5 by floor(5/2) = floor(5/2) = 2, namely, 2 and 3, also differ by 1 from their nearest multiples of 2 and 3.
The table below illustrates the first four terms. (In the table, 2*floor(k/2) is arbitrarily listed as the "nearest multiple" of 2 for each value of k; choosing 2*ceiling(k/2) would give the same resulting terms.)
.
| nearest | abs. diff. from |
| multiple of | nearest multiple of|
k | 2 3 5 7 | 2 3 5 7 | terms
---+----------------+--------------------+------------
1 | 0 0 0 0 | *1*--*1* 1 1 | a(1), a(2)
2 | 2 3 0 0 | 0 *1* *2* 2 |
3 | 2 3 5 0 | *1* 0 *2* *3* |
4 | 4 3 5 7 | 0 *1* 1 *3* |
5 | 4 6 5 7 | *1* *1* 0 2 |
6 | 6 6 5 7 | 0 0 1 1 |
7 | 6 6 5 7 | *1*--*1*--*2* 0 | a(3)
8 | 8 9 10 7 | 0 *1* *2* 1 |
9 | 8 9 10 7 | *1* 0 1 2 |
10 | 10 9 10 7 | 0 *1* 0 *3* |
11 | 10 12 10 14 | *1* *1* 1 *3* |
12 | 12 12 10 14 | 0 0 *2* 2 |
13 | 12 12 15 14 | *1* *1* *2* 1 |
14 | 14 15 15 14 | 0 *1* 1 0 |
15 | 14 15 15 14 | *1* 0 0 1 |
16 | 16 15 15 14 | 0 *1* 1 2 |
17 | 16 18 15 14 | *1*--*1*--*2*--*3* | a(4)
PROG
(Magma) N:=21; p:=2; prod:=p; R:=[1]; a:=R; for n in [2..N] do p:=NthPrime(n); RR:=[]; u1:=p div 2; u2:=u1+1; for m in [0..p-1] do o:=m*prod; for r in R do t:=o+r; u:=t mod p; if (u eq u1) or (u eq u2) then RR[#RR+1]:=t; if n eq N then a[n]:=t; break n; end if; end if; end for; end for; R:=RR; a[n]:=R[1]; prod*:=p; end for; a;
(PARI) See Corneth link \\ David A. Corneth, May 09 2019
CROSSREFS
KEYWORD
nonn
AUTHOR
Jon E. Schoenfield, May 08 2019
STATUS
approved