OFFSET
1,3
COMMENTS
a(n) is the last residue modulo prime(n) in the minimal set of the first primes which contains all residues modulo prime(n).
Build the smallest set {prime(1), prime(2), ..., prime(k)} of the first k consecutive primes such that the set {prime(1) mod prime(n), prime(2) mod prime(n), ..., prime(k) mod prime(n)} contains all residues {0, 1, 2, ..., prime(n)-1}. Then a(n) = prime(k) mod prime(n). - R. J. Mathar, Oct 25 2010
EXAMPLE
If n=3, then prime(n)=5 and {2,3,5,7,11,13,17,19} is the minimal set of the first primes which contains all residues modulo 5. We have consecutive residues {2,3,0,2,1,3,2,4}. Therefore a(3)=4.
MAPLE
A178216 := proc(n) local p, k, modP, i ; p := ithprime(n) ; for k from 1 do modP := [seq( ithprime(j) mod p, j=1..k)] ; {seq(i, i=0..p-1)} minus convert(modP, set) ; if % = {} then return op(-1, modP) ; end if; end do: end proc: seq(A178216(n), n=1..50) ; # R. J. Mathar, Oct 25 2010
CROSSREFS
KEYWORD
nonn
AUTHOR
Vladimir Shevelev, May 22 2010
EXTENSIONS
a(10) corrected, more terms appended by R. J. Mathar, Oct 25 2010
Name corrected by Jon E. Schoenfield, May 10 2019
STATUS
approved