This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A047980 #29 Mar 19 2019 00:14:41 %S A047980 1,3,24,7,38,17,184,71,368,19,668,59,634,167,512,757,1028,197,1468, %T A047980 159,3382,799,4106,227,10012,317,7628,415,11282,361,38032,521,53630, %U A047980 3289,37274,2633,63334,1637,34108,1861,102296,1691,119074,1997,109474,2053 %N A047980 a(n) is smallest difference d of an arithmetic progression dk+1 whose first prime occurs at the n-th position. %C A047980 Definition involves two minimal conditions: (1) the first prime (as in A034693) and (2) dk+1 sequences were searched with minimal d. Present terms are the first ones in sequences analogous to A034780, A034782-A034784, A006093 (called there K(n,m)). %C A047980 Index of the first occurrence of n in A034693. - _Amarnath Murthy_, May 08 2003 %H A047980 Jon E. Schoenfield, <a href="/A047980/b047980.txt">Table of n, a(n) for n = 1..150</a> (terms 1..72 from Robert Israel) %H A047980 Jon E. Schoenfield, <a href="/A047980/a047980.txt">Terms <= 5*10^8: Table of n, a(n) for n = 1..406, with -1 for each term > 5*10^8</a> %H A047980 <a href="/index/Pri#primes_AP">Index entries for sequences related to primes in arithmetic progressions</a> %F A047980 a(n) = min{k | A034693(k) = n}. %e A047980 For n=2, the sequence with d=1 is 2,3,4,5,... with the prime 2 for k=1. The sequence with d=2 is 3,5,7,9,... with the prime 3 for k=1. The sequence with d=3 is 4,7,10,13,... with the prime 7 for k=2. So a(n)=3. - _Michael B. Porter_, Mar 18 2019 %p A047980 N:= 40: # to get a(n) for n <= N %p A047980 count:= 0: %p A047980 p:= 0: %p A047980 Ds:= {1}: %p A047980 while count < N do %p A047980 p:= nextprime(p); %p A047980 ds:= select(d -> (p-1)/d <= N, numtheory:-divisors(p-1) minus Ds); %p A047980 for d in ds do %p A047980 n:= (p-1)/d; %p A047980 if not assigned(A[n]) then %p A047980 A[n]:= d; %p A047980 count:= count+1; %p A047980 fi %p A047980 od: %p A047980 Ds:= Ds union ds; %p A047980 od: %p A047980 seq(A[i],i=1..N); # _Robert Israel_, Jan 25 2016 %t A047980 With[{s = Table[k = 1; While[! PrimeQ[k n + 1], k++]; k, {n, 10^6}]}, TakeWhile[#, # > 0 &] &@ Flatten@ Array[FirstPosition[s, #] /. k_ /; MissingQ@ k -> {0} &, Max@ s]] (* _Michael De Vlieger_, Aug 01 2017 *) %o A047980 (MATLAB) %o A047980 function [ A ] = A047980( P, N ) %o A047980 % Get values a(i) for i <= N with a(i) <= P/i %o A047980 % using primes <= P. %o A047980 % Returned entries A(n) = 0 correspond to unknown a(n) > P/n %o A047980 Primes = primes(P); %o A047980 A = zeros(1,N); %o A047980 Ds = zeros(1,P); %o A047980 for p = Primes %o A047980 ns = [1:N]; %o A047980 ns = ns(mod((p-1) * ones(1,N), ns) == 0); %o A047980 newds = (p-1) ./ns; %o A047980 ns = ns(A(ns) == 0); %o A047980 ds = (p-1) ./ ns; %o A047980 q = (Ds(ds) == 0); %o A047980 A(ns(q)) = ds(q); %o A047980 Ds(newds) = 1; %o A047980 end %o A047980 end % _Robert Israel_, Jan 25 2016 %Y A047980 Cf. A034693, A034694, A034780, A034782, A034783, A034784, A006093, A047981, A047982. %K A047980 nonn %O A047980 1,2 %A A047980 _Labos Elemer_